Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 16th, 2005, 11:51 PM
Sylvie Stone
Guest
 
Posts: n/a
Default 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.php">
<select name="loginform">
<option value="one">Section 1</option>
<option value="two">Section 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=\"autologin\" value=\"1\">\n";
echo "<input type=hidden name=\"formstyle\" value=\"standard\">\n";
echo "<input type=hidden name=\"returnforum\" value=\"_admin\">\n";
echo "<input type=hidden name=\"returnmsg\"
value=\"acahomepage\">\n";

} else {

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

}

  #2  
Old July 16th, 2005, 11:51 PM
Erwin Moller
Guest
 
Posts: n/a
Default Re: Form processing: change the "action=" 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>formactiontest</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Quanta Plus">

<script language="javascript">

function doSubmit(){
// get the chosen option
selind = document.forms.mydynamicform.selectaction.selected Index;
// get the value
selval = document.forms.mydynamicform.selectaction[selind].value;

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

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

}

</script>

</head>
<body>

<form action="unknownyet" METHOD="POST" name="mydynamicform">

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

</form>

</body>
</html>


Regards,
Erwin
  #3  
Old July 17th, 2005, 12:05 AM
Sylvie Stone
Guest
 
Posts: n/a
Default Re: Form processing: change the "action=" based on pull down menu

sylviestone@canada.com (Sylvie Stone) wrote in message news:<181a24a8.0309160650.45b744df@posting.google. 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.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.