Current location: Hot Scripts Forums » Programming Languages » PHP » Form with multiple actions and methods


Form with multiple actions and methods

Reply
  #1 (permalink)  
Old 06-03-05, 04:55 PM
amitroy5 amitroy5 is offline
Newbie Coder
 
Join Date: May 2005
Location: Mizoram, India
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Form with multiple actions and methods

Is this possible with PHP?

I have one form. It has a dropdown menu. One searches Google and the other is a site search that uses the "get" command for method. So, they have two different actoins. How can I have one form with two different actions? Thanks!
Reply With Quote
  #2 (permalink)  
Old 06-03-05, 07:25 PM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
u mean like:

<form action="post, get">
??

no

why not just have 2 seperate forms??

or maybe try:

<select name="searchtype"><option value="1">Search Google</option><option value="2">Search Site</option></select>

PHP Code:

<?php


//input for search criteria
$search $_POST['search'];

//google?
if ($_POST['searchtype'] == "1") {
header ("Location: http://www.google.com/search?q=$search");
}

//own site?
elseif ($_POST['searchtype'] == "2") {
include(
"searchresults.php");
}

else {
die(
"error - no search selected!");
}

?>
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
  #3 (permalink)  
Old 06-03-05, 08:37 PM
amitroy5 amitroy5 is offline
Newbie Coder
 
Join Date: May 2005
Location: Mizoram, India
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Well, it would be too much clutter to have multiple forms that just have one input text area.
Reply With Quote
  #4 (permalink)  
Old 06-04-05, 05:03 AM
dennispopel dennispopel is offline
Coding Addict
 
Join Date: Mar 2005
Posts: 263
Thanks: 0
Thanked 0 Times in 0 Posts
To answer your question - you CANNOT have one form with multiple actions, i.e., a form that actually triggers two requests. However, you can use scripting to automatically change the action attribute of the form to point to other destinations based on the value of the select field (i.e., use its onchange event to change the form's action attribute).
__________________
onPHP5.com - PHP5: Articles, News, Tutorials, Interviews, Software and more
Reply With Quote
  #5 (permalink)  
Old 06-04-05, 03:51 PM
amitroy5 amitroy5 is offline
Newbie Coder
 
Join Date: May 2005
Location: Mizoram, India
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
I want something like that. What you are talking about.

Quote:
Originally Posted by dennispopel
To answer your question - you CANNOT have one form with multiple actions, i.e., a form that actually triggers two requests. However, you can use scripting to automatically change the action attribute of the form to point to other destinations based on the value of the select field (i.e., use its onchange event to change the form's action attribute).
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 06:49 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.