View Full Version : change form action on the fly?

goomba Jon
03-09-2005, 06:58 AM
is there any way to change the action field in a form on the fly based on a button pressed? if so how can this done?

<input type="submit" name="yahoo" value="yahoo" onclick=this.form.action.value='yahoo.com';this.form.submit();>
<input type="submit" name="google" value="google" onclick=this.form.action.value='google.com';this.form.submit();>

i am aware there that most people use form processing scripts, but doing this begins to cause alot of problems and doesnt follow the rules of the fusebox methodology i am using.


03-09-2005, 07:13 AM
isn't it just

document.forms[0].action = "index.cfm";
this.form.action = "index.cfm";

03-09-2005, 08:02 AM
You don't have to submit it as the button is already a submit button.

<input type="submit" name="yahoo" value="yahoo" onclick="this.form.action.value='http://www.yahoo.com';" />
<input type="submit" name="google" value="google" onclick="this.form.action.value='http://www.google.com';" />

If you are really submitting to an external site, you need to put http://