473,324 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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".

}
Jul 16 '05 #1
2 11412
Sylvie Stone wrote:
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!


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
Jul 16 '05 #2
sy*********@canada.com (Sylvie Stone) wrote in message news:<18**************************@posting.google. com>...
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!

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.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Aatu Koskensilta | last post by:
When processing HTML-files for various purposes, I run into a strange form action definition looking like "r/sx/*-http://somehow/somescript" In particular, the Yahoo search form uses a form...
3
by: Zhidian Du | last post by:
I am using java to write to url, http://fatigo.bioinfo.cnio.es/ , but I found the form is : <form method="post" action="/" enctype="multipart/form-data" name="fatigo"> I have no idea why...
7
by: M | last post by:
i have a form which i would like to input different "action" url depending on the button that was clicked. is there a way that javascript can prefill a defined action based on the button...
1
by: tnhoe | last post by:
Hi, <Form method='post' action="next.htm?btn="+"this.myform.myobj.value"> What is the correct syntax for above ? Regards Hoe
3
by: asianboi | last post by:
Hi, In my application, I have a web browser control and load up a local html page. Within the html page, the following code exists. However, when I click on the button that invokes the 'form...
4
by: Bosconian | last post by:
I have created a form tool page that consists of several dropdowns which allows a user to drill down and select a desired document for viewing in an external window. I need to post the form data to...
6
by: Arthur | last post by:
Hello. How might it be possible to change where a form action is directed based on a selected option. For example I have this: <FORM METHOD = "post" ACTION = ""> And a drop down such as
3
by: phpnewbie2007 | last post by:
Hello, I have a dropdown which populates from a database. When user selects option 1 from the dropdown, he should be directed to sample.php, if he selects option 2, then to sampleb.php and so on....
8
by: webandwe | last post by:
Hi, I have to radio buttons and depending on the selection it must eighter insert step2.php or insert.php in the action part of the form. Now it's just going to steo2.php I also tried elseif...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.