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
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts

    one select list updates all select lists

    Hey Guys
    When a user changes the select list called "reason_code_master" I need the uodatecodes() function to update all the other select list with the id of "reason_codes" with the same . How can I do this.


    <select size='1' onchange="updatecodes()" name='reason_code_master'>
    <option value='' > - SET REASON - </option>
    <option value='BROKEN' >BROKEN</option>
    <option value='ENTERED' >ENTERED</option>
    <option value='SHORT' >SHORT</option>
    </select>

    <select size='1' name='reason_codes' id='reason_codes'>
    <option value='' > - SET REASON - </option>
    <option value='BROKEN' >BROKEN</option>
    <option value='ENTERED' >ENTERED</option>
    <option value='SHORT' >SHORT</option>
    </select>
    <select size='1' name='reason_codes' id='reason_codes'>
    <option value='' > - SET REASON - </option>
    <option value='BROKEN' >BROKEN</option>
    <option value='ENTERED' >ENTERED</option>
    <option value='SHORT' >SHORT</option>
    </select>
    <select size='1' name='reason_codes' id='reason_codes'>
    <option value='' > - SET REASON - </option>
    <option value='BROKEN' >BROKEN</option>
    <option value='ENTERED' >ENTERED</option>
    <option value='SHORT' >SHORT</option>
    </select>
    <select size='1' name='reason_codes' id='reason_codes'>
    <option value='' > - SET REASON - </option>
    <option value='BROKEN' >BROKEN</option>
    <option value='ENTERED' >ENTERED</option>
    <option value='SHORT' >SHORT</option>
    </select>

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,098
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    ID values MUST be unique.

    Also, has been asked/answered on a different forum:
    See: http://www.webdeveloper.com/forum/sh...ghlight=select

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,146
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    You may not have multiple elements with the same id.

    Is this what you desire?


    Code:
    <select size='1' onchange="updatecodes()" name='reason_code_master' id ='reason_code_master' >
    <option value='' > - SET REASON - </option>
    <option value='BROKEN' >BROKEN</option>
    <option value='ENTERED' >ENTERED</option>
    <option value='SHORT' >SHORT</option>
    </select>
    
    <select size='1' name='reason_codes1' id='reason_codes1'>
    <option value='' > - SET REASON - </option>
    <option value='BROKEN' >BROKEN</option>
    <option value='ENTERED' >ENTERED</option>
    <option value='SHORT' >SHORT</option>
    </select>
    <select size='1' name='reason_codes2' id='reason_codes2'>
    <option value='' > - SET REASON - </option>
    <option value='BROKEN' >BROKEN</option>
    <option value='ENTERED' >ENTERED</option>
    <option value='SHORT' >SHORT</option>
    </select>
    <select size='1' name='reason_codes3' id='reason_codes3'>
    <option value='' > - SET REASON - </option>
    <option value='BROKEN' >BROKEN</option>
    <option value='ENTERED' >ENTERED</option>
    <option value='SHORT' >SHORT</option>
    </select>
    <select size='1' name='reason_codes4' id='reason_codes4'>
    <option value='' > - SET REASON - </option>
    <option value='BROKEN' >BROKEN</option>
    <option value='ENTERED' >ENTERED</option>
    <option value='SHORT' >SHORT</option>
    </select> 
    
    <script type = "text/javascript">
    function updatecodes() {
    var si = document.getElementById("reason_code_master").selectedIndex;
    for (var i=1; i<=4; i++) {
    var rc = "reason_codes" + i;
    document.getElementById(rc).selectedIndex = si;
    }
    }
    </script>


    "When I was a kid I used to pray every night for a new bike. Then I realised that The Lord doesn't work that way, so I stole one and asked him to forgive me."


  •  

    Posting Permissions

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