1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Set Dropdown element

Discussion in 'JavaScript' started by Hosea, Apr 13, 2012.

  1. #1
    HiI have DropdwonList with elements, 1,2,3 and 4.. and I have another DropdownList with options Normal, Standard, Emegency, and expendited.Can you help me with javascript code, so that when I select "1" option on the first dropdown, the "Emegency" option on the second dropdown is set/selected.Thanks in advance
     
    Hosea, Apr 13, 2012 IP
  2. e-abi

    e-abi Member

    Messages:
    122
    Likes Received:
    1
    Best Answers:
    3
    Trophy Points:
    38
    #2
    When using jQuery, then the snippet below should work.
    It says that when I change the first select element, then locate out the elemnt with id=second and set it's value to the value of current select element.


    
    <form>
    <table>
    <tbody>
    <tr>
      <td>
        <select id="first" name="year" onchange="$('#second').val($(this).val());">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">2</option>
          <option value="4">2</option>
        </select>
      </td>
    </tr>
    <tr>
      <td>
        <select id="second" name="section">
          <option value="1">Normal</option>
          <option value="2">Standard</option>
          <option value="3">Emergency</option>
          <option value="4">Expedited</option>
        </select>
      </td>
    </tr>
    </tbody>
    </table>
    </form>
    
    PHP:

    If you want to learn jQuery, go here: http://jquery.com/
     
    e-abi, Apr 13, 2012 IP
  3. Hosea

    Hosea Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm using JQuery.
     
    Hosea, Apr 15, 2012 IP
  4. e-abi

    e-abi Member

    Messages:
    122
    Likes Received:
    1
    Best Answers:
    3
    Trophy Points:
    38
    #4
    Then my submitted code snippet should work.
     
    e-abi, Apr 16, 2012 IP
  5. javamazon

    javamazon Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    66
    #5
    Replace your URL in the URLs in the attached code js.html file..its working code
     

    Attached Files:

    • js.html
      File size:
      589 bytes
      Views:
      52
    javamazon, Apr 20, 2012 IP
  6. raspms

    raspms Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ITS really nice posting..thanks for sharing..
     
    raspms, Apr 25, 2012 IP
  7. javamazon

    javamazon Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    66
    #7
    Thanks , Hope that worked for you .
     
    javamazon, Apr 25, 2012 IP