...

View Full Version : Changing form action



lupes
09-04-2007, 05:51 PM
Hi,

I searched the forums and found a few people asking this but i didn't understand any responses.

I have a simple form with a drop down


<form name="test" action="">
<select name="change">
<option value="page1.htm">page1</option>
<option value="page2.htm">page2</option>
<option value="page3.htm">page3</option>
</select>

<input name="submit" type="submit" value="submit" />
</form>

I'd like the form action to change depending on the option selected.

If page 1 is selected then the form action would be 'page1.htm'

If page 2 is selected then the form action would be 'page2.htm' and so on.

Can someone please help me by explaining how i'd do this.

Thanks in advance.

PremiumBlend
09-04-2007, 06:20 PM
Do you want other data to submit to that page or just open that page?

jryoung
09-04-2007, 06:50 PM
Try this version:


<html>
<head>
<title>Remote Control</title>
</head>
<body bgcolor="#FFFFFF">
<form name="combo">
<p><select name="go" size="1" onChange="window.location=this.options[this.selectedIndex].value">
<option value=" " Selected>Select One</option>
<option value="http://www.javascriptkit.com">Web Building Tutorials</option>
<option value="http://www.mvsforums.com">MVS Help</option>
</select>
</p>
</form>
</body>
</html>

lupes
09-04-2007, 08:50 PM
Do you want other data to submit to that page or just open that page?



Hi there,

i just want to open that page that's all.

lupes
09-04-2007, 08:50 PM
Try this version:


<html>
<head>
<title>Remote Control</title>
</head>
<body bgcolor="#FFFFFF">
<form name="combo">
<p><select name="go" size="1" onChange="window.location=this.options[this.selectedIndex].value">
<option value=" " Selected>Select One</option>
<option value="http://www.javascriptkit.com">Web Building Tutorials</option>
<option value="http://www.mvsforums.com">MVS Help</option>
</select>
</p>
</form>
</body>
</html>


i'll try that, thanks.

felgall
09-04-2007, 08:55 PM
If you want it to work with JavaScript disabled then you need to use a server side script to do the redirect to the selected page. The form needs to have the action set to that server side script. That then doesn't get called if the JavaScript code redirects to the selected page.

lupes
09-04-2007, 11:19 PM
If you want it to work with JavaScript disabled then you need to use a server side script to do the redirect to the selected page. The form needs to have the action set to that server side script. That then doesn't get called if the JavaScript code redirects to the selected page.

Server side sounds like it would be better, but again i have no idea how to go about it.

I'm willing to try whatever's most effective - if you can help?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum