submit a different form than action

Javascript coding ..

Moderators: macek, egami, gesf

User avatar
popeye
New php-forum User
New php-forum User
Posts: 120
Joined: Sat Jan 03, 2004 7:06 pm
Location: New York, NY

submit a different form than action

Postby popeye » Mon Apr 25, 2005 2:12 pm

How can I submit a form using a <a href='xxxxx'>Submit</a> (be able to retrieve its values using "POST") and load a different page other the one that was indicated in the “action” parameter of the form?
Thanks

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Mon Apr 25, 2005 3:49 pm

To submit a form through a text use something like:

Code: Select all

<a href="javascript:document.form_name.submit();">Submit</a>


You can change the form's action via javascript.
But.... what are you trying to do ?

User avatar
popeye
New php-forum User
New php-forum User
Posts: 120
Joined: Sat Jan 03, 2004 7:06 pm
Location: New York, NY

Postby popeye » Mon Apr 25, 2005 6:21 pm

It is not that I want to submit the form only. It is that I want to submit the form and then load a different page than the one set in the action="xxxx.php".

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Mon Apr 25, 2005 9:47 pm

But will the page set in the form's action be the submition destination as same ?
You can use the form's onsubmit method.

Example:

Code: Select all

<form method="post" action="index.php" onsubmit="javascript:window.open('http://www.test.com/test.php','mywindow');">
....


Regards

sadisticmachine
New php-forum User
New php-forum User
Posts: 109
Joined: Tue Nov 02, 2004 5:33 am

Postby sadisticmachine » Tue Apr 26, 2005 4:44 am

Try this:

Code: Select all

<a href = "JavaScript: document.form_name.action='desired_target.php'; document.form_name.submit()">Link</a>

User avatar
popeye
New php-forum User
New php-forum User
Posts: 120
Joined: Sat Jan 03, 2004 7:06 pm
Location: New York, NY

Postby popeye » Tue Apr 26, 2005 6:55 am

:grin:

It worked great. You helped me before while back. I should call you "sadisticHELPmachine".

Thanks


Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 1 guest

cron