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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form action question

Status
Not open for further replies.
Jun 9, 2004
188
US
Hello this might be a simple question:

I have a form with two radio buttons and a submit button. I am trying to incorportate a form action based on the radio selection. I was thinking of doing something like

If radio1 is selected the do action=\"search1.php\"
If radio2 is selected the do action=\"search2.php\"

Do I have the right idea with this? I am confused on how I would tell the form action on what search page to use. Any ideas would help me out a lot. Thanks guys.

Code:
<form action=\"     \" method=\"post\">
	
	<input type=\"text\" name=\"search_value\" size=\"15\"> 
	
	<input type=\"radio\" name=\"group1\" value=\"radio1\" checked> Radio button 1
	<input type=\"radio\" name=\"group1\" value=\"radio2\"> Radio Button 2
	<input type=\"submit\"  value=\"Search\" style=\"font-family: Verdana; font-size: 10px\">
 
You'll have to use JavaScript or VBScript if you want the form to directly submit to one of a series of specific scripts based on user input. PHP runs on the server, not the client.

If you want PHP to handle this, I recommend that you incorporate both search functions into one script (to which the form always submits) then have that one script react to the input.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
You would have to have a single form action (you can't have two) then in the action see what the radio buttons were set to and act accordingly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top