Click to See Complete Forum and Search --> : can i add my own value in a drop down menu ?
jean-baptiste
06-22-2003, 04:41 PM
Is it possible to have an entry field in an drop down menu ?
For example in the code should be:
<SELECT SIZE="1" name="cours">
<OPTION>one</OPTION>
<OPTION>two</OPTION>
<OPTION value =""></OPTION>
</select>
For the attribute value of option, can we entry a value from the html page ?
If isn't possible, what are the others solutions ?
Thank you
Greelmo
06-22-2003, 04:56 PM
I don't think i am reading your question correctly... are you saying you want the user to type a value in somewhere and have it appear on the dropdown?
jean-baptiste
06-22-2003, 06:00 PM
No Greelmo,
I am saying i want the user to type a value on the dropdown and have it appear on the dropdown?
In fact, the user can choose a value or to type a value on the dropdown.
For example the user can to type a value on a country dropdown because the dropdown doesn't propose the country where he comes from.
Do you see what i mean ?
Thanks a lot.
Something like the below untested code?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 //EN">
<html lang="en">
<head><title>Adding values to a select box, via JavaScript</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Content-Script-Type" content="text/javascript">
</head>
<body>
<form action="" name="anyForm"><div>
<select size="1" name="sel" onChange="alert(this.options[this.options.selectedIndex].value);">
<option selected value="">One</option>
<option value="">Two</option>
<option value="">Three</option><br>
<input type="text" name="t1"><br>
<input type="text" name="t2"><br>
<input type="text" name="t3"><br>
<input type="button" onClick="for(i=0;i<this.form.sel.options.length;i++){
eval('this.form.sel.options[this.form.sel.options['+i+']].value=this.form.t'+i+'.value');}">
</div></form>
</body></html>
Jona