Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    406
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to create d dropdown like this

    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.

  • #2
    New Coder
    Join Date
    Aug 2002
    Location
    Pakistan
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    adding an entry to the select field:
    Code:
    <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>
    To steal ideas from one person is plagiarism, to steal ideas from many is research.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •