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

Forum action and field name issue

Status
Not open for further replies.

iggitme

IS-IT--Management
Sep 13, 2006
47
US
Greetings Great Gurus!

I am in need of a routine to allow this to happen and would greatly appreciate any help in this vein:

there are two search forms that need to be merged into one text entry box

i'm using radio buttons to determine what to search in, but the two forms have different named text boxes and of course, different action scripts

is there a routine i can use that allows the selection of a radio option to determine the name of the text input field as well as the url to send the form too?



thank you very much
 
Something like this?


Code:
<script>
function Change_Search(Srch_Opt){
var the_form=document.getElementById('myform');
var Txt_Box=document.getElementById('mytxtbox');

if(Srch_Opt.value=='searchA'){
the_form.action="actionA.cgi";
Txt_Box.name="nameA";
}
if(Srch_Opt.value=='searchB'){
the_form.action="actionB.cgi";
Txt_Box.name="nameB";
}
}
</script>
...
<form action="" method=POST id="myform">
<input type=text name="" id="mytxtbox">
<input type=radio name="srch" value="searchA" onClick="Change_Search(this);">
<input type=radio name="srch" value="searchB" onClick="onClick=Change_Search(this);">

<input type=submit name="send" value="Search">
</form>




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Bless you!
Thank you so very very much!
 
Incidentally, you're better off not setting the action client-side, instead having one server-side action that detects which radio button was selected and performs the desired action.

That way, people without JS enabled will be able to use both search methods.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Yes sir I agree. In this instance I can't. Normally I would assign using a Perl script as that is what I would process the form with, but not so this time. Rather strange obtuse treatment of PHP so templated it nearly makes its own sense. Thank you for the response!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top