...

View Full Version : how to create d dropdown like this



chelvis
12-03-2002, 06:05 PM
I creating a form and it that I want to create a dropdown menu. But at the same time I want to give the user a flexibility to enter something new or select some thing from the dropdown. How can I do this? (like a combo box)

<form>
<select name="country">
<option value="usa">USA</option>
<option value="UK">UK</option>
<option value="canada">Canada</option>
</select>
</form>

Here the user/administrator of the webpage should be able to add a new country or select an existing one for a particular customer.

mhere
12-03-2002, 07:32 PM
adding an entry to the select field:


<HTML>
<HEAD>

<SCRIPT TYPE=Text/JavaScript>
function add()
{
var coun = document.form1.country;
var text = document.form1.input1.value;
var value = document.form1.input2.value;
var option = new Option(text,value);
coun.options[coun.length] = option;
}
</SCRIPT>
</HEAD>

<BODY>

<FORM NAME=form1>
Text for the new entry <INPUT NAME=input1><br>
Value of the new entry <INPUT NAME=input2><br><br>
<INPUT TYPE=button VALUE="Add" NAME=addtext onclick="add()">

<BR><BR>

<select name="country">
<option value="usa">USA</option>
<option value="UK">UK</option>
<option value="Canada">Canada</option>
</select>


</FORM>
</BODY>
</HTML>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum