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 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    28
    Thanks
    2
    Thanked 0 Times in 0 Posts

    select onchange -> populate textbox

    i'm having trouble with populating a textbox in a seperate form on the same page when the select option is changed:

    the following onchange doesnt work.... can someone tell me how to fix this:

    <div id="dropdown1">
    <form action="" class="niceform">
    <select size="1" id="mySelect1" name="mySelect1" class="width_130" onchange="document.searchbox.searchquery.value=this.selectedIndex">
    <option selected="selected" value="Blah">Blah</option>
    <option value="Test">Test</option>
    <option value="Test2">Test 2</option>
    <option value="Test3">Test 3</option>
    </select>
    </form>
    </div>
    <div id="dropdown2">
    <form action="" class="niceform">
    <select size="1" id="mySelect2" name="mySelect2" class="width_170" onchange="document.searchbox.searchquery.value=this.selectedIndex">
    <option selected="selected" value="Blah2">Blah2</option>
    <option value="Test">Test</option>
    <option value="Test 2">Test 2</option>
    <option value="Test 3">Test 3</option>
    </select>
    </form>
    </div>
    <div id="searchbox">
    <form action="" name="searchbox">
    <input name="searchquery" id="searchquery" value="Search" onfocus="if (this.value == 'Search') this.value = '';" type="text" class="form" />
    <input name="" type="submit" class="search" value="" />
    </form>

  • #2
    New Coder
    Join Date
    Sep 2006
    Posts
    32
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Instead of this.selectedIndex try:
    this.options[this.selectedIndex].value

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    28
    Thanks
    2
    Thanked 0 Times in 0 Posts
    not working... 3 forms may be causing an issue?


  •  

    Posting Permissions

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