Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

submit a different form than action

Javascript coding ..

Moderators: macek, egami, gesf

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
popeye
New php-forum User
New php-forum User
 
Posts: 120
Joined: Sat Jan 03, 2004 7:06 pm
Location: New York, NY

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
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

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
popeye
New php-forum User
New php-forum User
 
Posts: 120
Joined: Sat Jan 03, 2004 7:06 pm
Location: New York, NY

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
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

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>
sadisticmachine
New php-forum User
New php-forum User
 
Posts: 109
Joined: Tue Nov 02, 2004 5:33 am

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


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron