Results 1 to 1 of 1

Thread: Passing variable in dropdown menu to a button

  1. #1
    Join Date
    Jan 2009
    Location
    Calgary Alberta
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Passing variable in dropdown menu to a button

    Hi all,

    I am currently working on a web-page that parses an XML file and puts it into HTML. What I have are three sorting buttons to sort the rows to list them alphabetically etc. The code for the buttons is below and it is working perfectly fine.

    Code:
    <INPUT TYPE=BUTTON VALUE="Sort By Name" onclick="sort(sortName.XMLDocument);">
    <INPUT TYPE=BUTTON VALUE="Sort By Patient ID" onclick="sort(sortNumber.XMLDocument);">
    <INPUT TYPE=BUTTON VALUE="Get Names A through M" onclick="sort(getAtoM.XMLDocument);">
    What I want to do though is take away the buttons and make them a dropdown list and a go button. I have tried the following code and it doesn't work.

    Code:
    <form name="docSortList">
    <select name="sort">
    <option value="sort(sortName.XMLDocument);">Sort By Name</option>
    <option value="sort(sortNumber.XMLDocument);">Sort By Patient ID</option>
    <option value="sort(getAtoM.XMLDocument);">Get Names A through M</option>
    </select>
    <input type="button" onClick="location=document.docSortList.sort.options[document.docSortList.sort.selectedIndex].value;" value="GO">
    </form>
    When I click on the go button, it opens up a blank page.

    I have a feeling it has something to do with the "location=document......." since I am not wanting it to go to a location, i want it to carry out an action.

    Still working on it but any guidance would be greatly appreciated.

    Thanks.
    B
    Last edited by brent.fraser; 08-21-2009 at 08:06 PM. Reason: Resolved in: http://www.dynamicdrive.com/forums/showthread.php?t=47782

Bookmarks

Posting Permissions

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