Onchange with Post

Discussion in 'JavaScript' started by cyclopsvs, Aug 10, 2006.

  1. #1
    Hello javascript users,

    I'm a newby in web programming and i'm wondering if the following can be done. I have a select box in a form with multiple choises and the action of every choise will go to a different url.

    my question is if it's possible to take along all the pre defined variables to the next url, just like a post method from a form would do.

    the syntax i have till now is this:

    <form name='screening' action="http://anewpage" method="post">
    <table>
    <tr valign='baseline'>
    <td nowrap align='left'>Normal plasma:</td>
    <td><input type='text' name='rrf_la' size='15'></td>
    </tr>

    <tr valign='baseline'>
    <td align="left" valign="top">Type of assay:</td>
    <td>
    <select name='ass_la' WIDTH='150' STYLE='width: 150px' ONCHANGE='location = this.options[this.selectedIndex].value;'>
    <option value='http://APTT'>APTT</option>
    <option value='http://DRVVT'>DRVVT</option>
    </select>
    </td>
    </tr>
    </table>
    </form>


    any suggestions would be appreciated,

    richard mendes
     
    cyclopsvs, Aug 10, 2006 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    So you are wanting to pass the "rrf_la" variable to the new page "http://DRVVT" for example? Or just redirect to http://DRVVT?
     
    mad4, Aug 10, 2006 IP
  3. cyclopsvs

    cyclopsvs Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Indeed i want to pass that variable and some others to the page http://DRVVT
     
    cyclopsvs, Aug 10, 2006 IP
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try something like this:
    <script language="JavaScript">
    <!--
    function yourfunction(yourform){
    	yourform.action = "http://www.newpage.com/page.htm?variable=" + yourform.somevariable.value + "";
    	return true;
    }
    //-->
    </script>
    <input type="button" value="Submit" onclick="yourfunction();">
    Code (markup):
     
    mad4, Aug 10, 2006 IP
  5. cyclopsvs

    cyclopsvs Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ok thanks that helps a lot
     
    cyclopsvs, Aug 10, 2006 IP