Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Form Action Attribute?

Status
Not open for further replies.

Greenster

Programmer
Jan 14, 2002
30
0
0
GB
Can I change the form action with an onlcick event? My form action is defaulted to "file1.php" but I want it to change to "file2.php" if a user hits a particular button. Is this possible??

I have been trying....

function change_action(mainform){
mainform.action.value = "form2.submit();
}
Thanks in advance.
{Greenster}
{Greenster}
 
Hi,

I have changed the code to:

function change_action(mainform){
mainform.action = "form2.submit();
}

It does redirect the script but I first get a error "Object doesn't support this property or method" and my POSTED VARS are all lost ? ? ? {Greenster}
 
ok... :(

let's see. when reading your code I have the feeling that change_action() only changes the action and then submits the form.

The argument (mainform) of your function is it document.form2?

Could you have a consisten way of accessing your form?

for example :

function change_action(myForm){
myForm.action = " myForm.submit();
}
then later in the code

change_action(document.form2)

or simply :

function change_action(newAction){
document.form2.action = newAction;
document.form2.submit();
}
then later in the code :

change_action("
I have the feeling that mainform didn't really exist and that document.form2 is what you want to change. Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top