Click to See Complete Forum and Search --> : changing list/menu values


4thstar
08-10-2003, 04:40 AM
Hello everyone.

I was hoping someone could let me know how to do this :)

right , i have a form on my site , i wanted to set the value of a hidden field using a perl script..this bit i can do ( i hope )

now when the page loads i want to change the values of a list/menu option to suite..

for example :
if hidden field = "co.uk" then only display "2","4","6","8","10" in the list/menu dropdown called "noyears"

can anyone suggest how i can do this ?

Kind Regards
Carl

CrazyGaz
08-10-2003, 05:03 AM
<script language="javascript">
function check() {
if (document.form1.domain.value == '.co.uk') {
document.form1.menu1.value='hello'
document.form1.menu2.value='gaz'
}
}
</script>

<form name="form1" OnSubmit="check()">
<input type="text" name="domain" />
<input type="submit" value="submit">
<select> <option selected name="menu1" value="01"><option name="menu2" value="02"></select>
</form>

something like that?

4thstar
08-10-2003, 05:21 AM
Thankyou for that quick help , its great , but because i am new with this sort of thing i only assume i must be doing something slightly wrong ..
below is wthe demo page i have created..
You will see a hidden fieled called domaintype , so when the page loads from the script this field will change values , so on load if this value is .co.uk how do i get the values in the list/menu to change ?
i tried a little to play with what you supplied before but didnt get any changes :) its just me i know lol
Thank you again .


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function check() {
if (document.form1.domain.value == '.co.uk') {
document.form1.menu1.value='hello'
document.form1.menu2.value='gaz'
}
}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000"><form name="form1" OnSubmit="check()">
<input type="hidden" name="domaintype" value=".co.uk">
<input type="text" name="domain" />
<input type="submit" value="submit">
<select class="gaztextarea" size="1">
<option selected name="menu1" value="01"><option name="menu2" value="02"></select>
</form>

</body>
</html>

Khalid Ali
08-10-2003, 09:18 AM
Here is what you need to do.

in the onload event of the page call a function of sorts..
say...loadData()

in this function reference the select box and then create the fields

to create the fields/options n a select box
1. get the reference to the listbox element
var listbox = document.getElementById("listBoxName");
//now

listBox[index] = new Option(text,value);

//to remove items

listBOx.removeChild(option);

4thstar
08-10-2003, 12:29 PM
Thanks , its great to get the help .
But I am quite new to this type of thing , and that last bit went way over my head. sorry.

so you see my test page so far , ( my last post above )
this is a complete page ( basic ) so what would i need to do on this page ?

if someone can make this page so that the values in the dropdown change if the value of the hidden field changes to .co.uk then i will be off :)

Thanks for any help...

I think at first i need someone to show me what to do lol , not tell me how lol

Kind Regards
Carl