Form processing: change the "action=" based on pull down menu

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sylvie Stone

    #1

    Form processing: change the "action=" based on pull down menu

    Hi group -

    I have an html form for that uses username and password to login to a
    specific area of the website. The "area" the user wants to go to is
    based on a pull down menu. Becasue the user/password info is in
    differnet databases, how can I call different validation scripts based
    on this input ?
    THANK YOU!

    See below please. Somethinglike this:

    form.html:
    <form name="loginform " method="post" action="login.p hp">
    <select name="loginform ">
    <option value="one">Sec tion 1</option>
    <option value="two">Sec tion 2</option>
    </select>

    login.php:

    @extract($_POST );
    if($_POST[loginform] == "one") {

    echo "action = /forums/scc/dispatch.cgi/_admin/AVFLogin"
    NAME="LoginForm " >
    echo "<input type=hidden name=\"autologi n\" value=\"1\">\n" ;
    echo "<input type=hidden name=\"formstyl e\" value=\"standar d\">\n";
    echo "<input type=hidden name=\"returnfo rum\" value=\"_admin\ ">\n";
    echo "<input type=hidden name=\"returnms g\"
    value=\"acahome page\">\n";

    } else {

    echo "action = /path to different cgi \n";
    echo :different values for hidden fields".

    }
  • Erwin Moller

    #2
    Re: Form processing: change the &quot;action=&q uot; based on pull down menu

    Sylvie Stone wrote:
    [color=blue]
    > Hi group -
    >
    > I have an html form for that uses username and password to login to a
    > specific area of the website. The "area" the user wants to go to is
    > based on a pull down menu. Becasue the user/password info is in
    > differnet databases, how can I call different validation scripts based
    > on this input ?
    > THANK YOU![/color]

    Hi,

    This is actually a javascript trick you need.
    You can dynamically set the action of a form, just by assigning a new value
    to it.

    Try something like this:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
    <html>
    <head>
    <title>formacti ontest</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="GENERATOR " content="Quanta Plus">

    <script language="javas cript">

    function doSubmit(){
    // get the chosen option
    selind = document.forms. mydynamicform.s electaction.sel ectedIndex;
    // get the value
    selval = document.forms. mydynamicform.s electaction[selind].value;

    // now set this value as action for the form
    document.forms. mydynamicform.a ction=selval;

    // and submit
    document.forms. mydynamicform.s ubmit();

    }

    </script>

    </head>
    <body>

    <form action="unknown yet" METHOD="POST" name="mydynamic form">

    Choose your action:
    <select name="selectact ion">
    <option value="login1.p hp">go to login 1</option>
    <option value="login2.p hp">go to login 2</option>
    <option value="login3.p hp">go to login 3</option>
    </select>
    <br>
    Your name? <input type="text" name="yourname" size=10>
    <br>
    <input type="button" onClick="doSubm it()" value="Go!">

    </form>

    </body>
    </html>


    Regards,
    Erwin

    Comment

    • Sylvie Stone

      #3
      Re: Form processing: change the &quot;action=&q uot; based on pull down menu

      sylviestone@can ada.com (Sylvie Stone) wrote in message news:<181a24a8. 0309160650.45b7 44df@posting.go ogle.com>...[color=blue]
      > Hi group -
      >
      > I have an html form for that uses username and password to login to a
      > specific area of the website. The "area" the user wants to go to is
      > based on a pull down menu. Becasue the user/password info is in
      > differnet databases, how can I call different validation scripts based
      > on this input ?
      > THANK YOU![/color]


      THANKS A LOT to Erwin and NC for posting two excellent solutions.
      i have taken bits from each and implemented the code and it's working very well.

      Thanks again,

      Syl.

      Comment

      Working...