Linking ComboBox with a Text Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Benjamin Anthony
    New Member
    • Mar 2010
    • 4

    Linking ComboBox with a Text Box

    Hi i have a very little knowledge of HTML
    I am Doing my School Project and need a help.
    I want to link a combobox to a textbox
    say if i select a value from the combobox a particular text should appear in the text box.
    EXAMPLE : The combobox has a list of Science Questions. If i select Question 1 then the answer for that question should appear in the textbox.

    I donot require the answer to be fetched from any external source. It should be mentioned in the script.
  • Mayur2007
    New Member
    • Aug 2007
    • 67

    #2
    Hello Benjamin Anthony,

    Look at the below code this will help you....

    <script type="text/javascript" language="javas cript">
    function FillTextBox(obj ) {
    document.getEle mentById("textb ox1").value = obj;
    }
    </script>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" >
    <tr>
    <td>
    <select name="combo1" id="combo1" onchange="FillT extBox(this.val ue)">
    <option value="">Select Answer</option>
    <option value="ans1">An swer 1</option>
    <option value="ans2">An swer 2</option>
    <option value="ans3">An swer 3</option>
    <option value="ans4">An swer 4</option>
    </select>
    </td>
    <td>
    <input type="text" name="textbox1" id="textbox1" />
    </td>
    </tr>
    </table>
    Thanks & Regards,
    Mayur Bhayani

    Comment

    • Benjamin Anthony
      New Member
      • Mar 2010
      • 4

      #3
      thank you very much 90% of my job is done.
      However Text box seems to be very small, i tried increasing size but it increased only horizantly. I tried to replace textbox by textarea. The textarea was created but it failed to link with the combo box. Can you please help me by replacing the text box by an textarea and giving a readonly attribute to textarea.

      There would be an added advantage if you can give me the coding to retrive the data from an excel sheet. Say if i select an option from the combobox then a value from a perticular cell from an excel sheet should appear in the textarea in readonly mode.
      This will help me in future, if i need to change my answer then i only have to change the value in excel sheet.

      Comment

      • Mayur2007
        New Member
        • Aug 2007
        • 67

        #4
        Hello,

        Check your last question on the forum I had make answer on this..

        Thanks & Regards,
        Mayur Bhayani.

        Comment

        Working...