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
    Oct 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    writing a function to select an option in a select dropdown list based on the label

    i have a select dropdown list, with 4 options like this..

    Code:
          <select name="riskstrategytype">
            <option value="">
            <option value="1">Business
            <option value="2">Final
            <option value="3">Technical
          </select>
    then say inside a cell in a table i have something like this:

    Code:
        <td id="selectedType">
          Final
        </td>
    is there a way where when i click a link/button have the select dropdown menu select whatever was in the cell?

    here's the example:

    www.chauzer.com/test/test.html

    i want it so that when they click on "The Title" link, in the drop down menu above it'll select "Final" because it says Final in the 2nd row/2nd col

    thanks

  • #2
    New Coder
    Join Date
    Oct 2005
    Posts
    87
    Thanks
    1
    Thanked 0 Times in 0 Posts
    This should do the trick:

    Code:
    <html>
    <head>
    <script>
    function change() {
    document.formname.riskstrategytype[2].selected = true;
    }
    </script>
    </head>
    <body>
    <form name="formname">
    <select name="riskstrategytype">
    <option value="0" selected>
    <option value="1">Business
    <option value="2">Final
    <option value="3">Technical
    </select>
    <input type="reset" value="reset">
    </form>
    <br><br>
    <a href="javascript:change();">Final</a>
    </body>
    </html>


  •  

    Posting Permissions

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