www.webdeveloper.com
Results 1 to 3 of 3

Thread: how to get a textbox on click in option in select

  1. #1
    Join Date
    Jan 2009
    Posts
    4

    how to get a textbox on click in option in select

    when u clik on it textbox has to come and it has to take option and it has to display in select box

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,412

    Question

    I don't understand the requirements.

    Do you have an example or some code attempts?

  3. #3
    Join Date
    Feb 2006
    Posts
    2,927
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Select to Input</title>
    <!-- testing only- includes literal script and inline css -->
    <script type="text/javascript">
    Code:
    onload= function(){
        var F=document.forms[0];    
        var sel=F['select_1'];
        var txt= F['input_1'];
        var index, val;
        sel.onchange= function(){
            index= sel.selectedIndex;        
            val= sel.value || sel.options[index].text;
            txt.value= val;
        }
    }
    </script>
    </head>

    <body>
    <h1>Select to Input Field</h1>

    <div style="font-size:1.25em">
    <form action="">
    <p>
    <label>select element
    <select name="select_1">
    <option selected="selected" value=" ">Choose an Option </option>
    <option value="1">Option 1 </option>
    <option value="2">Option 2 </option>
    <option value="3">Option 3 </option>
    <option value="4">Option 4 </option>
    <option value="5">Option 5 </option>
    </select>
    </label>
    <label>text input:<input type="text" value="text box" readonly="readonly" name="input_1" size="8"></label>
    </p>

    </form>
    </div>
    </body>
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles