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
    New to the CF scene
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing values in forms with dropmenu onChange

    I need some help with my drop menu updating the name of a textarea onchange. I have simplified the code i have so far to what i thought would work but im stuck. Any help would be greatly appreciated.

    Code:
    <!--THIS CHANGES THE VALUE OF THE TEXT AREA WITH onChange-->
    
    <form id="dropmenu">
    <select name="selectitem" onChange="textbox.itemID_update.value=dropmenu.selectitem.value">
    <option value="id=1">ID One</option>
    <option value="id=2">ID two</option>
    <option value="id=3">ID three</option>
    <option value="id=4">ID four</option>
    <option value="id=5">ID five</option>
    <option value="id=6">ID six</option>
    </select>
    </form>
    
    <form id="textbox">
    <input name="itemID_update" type="text" value="">
    </form>


    Code:
    <!--THIS IS WHAT IM ATEMPTING DO DO. I WOULD LIKE THE onChange TO SET THE NAME INSTEAD OF THE VALUE OF THE TEXT AREA-->
    
    <form id="dropmenu">
    <select name="selectitem" onChange="textbox.itemID_update.name=dropmenu.selectitem.value">
    <option value="id=1">ID One</option>
    <option value="id=2">ID two</option>
    <option value="id=3">ID three</option>
    <option value="id=4">ID four</option>
    <option value="id=5">ID five</option>
    <option value="id=6">ID six</option>
    </select>
    </form>
    
    <form id="textbox">
    <input name="itemID_update" type="text" value="1">
    </form>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Try
    Code:
    <select name="selectitem" onchange="document.getElementById('itemID_update').setAttribute('name',this.value);">
    <option value="id=1">ID One</option>
    <option value="id=2">ID two</option>
    <option value="id=3">ID three</option>
    <option value="id=4">ID four</option>
    <option value="id=5">ID five</option>
    <option value="id=6">ID six</option>
    </select>
    </form>
    
    <form id="textbox" >
    <input name="itemID_update" id="itemID_update" type="text" value="1"/>
    </form>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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