how to display in new text field when i add option from drop down list?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lonelylonely
    New Member
    • Dec 2010
    • 2

    how to display in new text field when i add option from drop down list?

    how to display in new text field when i add option from drop down list?
  • lonelylonely
    New Member
    • Dec 2010
    • 2

    #2
    how to display word in new text field when i add option from drop down list?

    Comment

    • AutumnsDecay
      New Member
      • Mar 2008
      • 170

      #3
      I'm not quite sure I understand what you're meaning, but I'll take a stab at it.

      If you have:

      Code:
      <select name="selectBox">   <option>1</option>   <option>2</otpion>   </select>
      You could simply add an 'onchange' javascript function to the element.

      Code:
      <select name="selectBox" onchange="myFunction();">   <option>1</option>   <option>2</otpion>   </select>
      The the <head> of your page you could put:

      Code:
      <script type="text/javascript">
      
      myFunction(){
          document.getElementById('textfield').html = "New text!";
      }
      
      </script>
      So what's happening is that you set a javascript function do something to an element with the id of 'textfield'. What you told it to do is change the html (text) of that element.

      When you make a selection with your SELECT element, the 'onchange' event is fired and does your javascript function.

      I hope this is clear enough.

      Comment

      Working...