Forum Moderators: phranque
On my site I have a small search engine and a web directory. Both scripts run independantly of each other but I would like to offer the option of searching either the "engine" or "directory" by allowing the user to check a box (with one selected by default)
when I construct a form I always specify at the start what script the form is going to interact with for example for the search engine it is...
<FORM METHOD="get" ACTION="/search/search.pl">
but for the directory it is...
<FORM METHOD="get" ACTION="/cgi-bin/search.cgi">
how could I offer the 2 options to different scripts from the one form???
However, if I understand correctly, you want to choose which form gets submitted and only submit the one.
I made a web search page for my site which had one input field and 4 buttons for different searches. 4 hidden forms held the individual searches.
On clicking one of the search buttons, a JS function reads the search term and writes it in the correct hidden form input and submits that hidden form to the correct destination.
Yours should work in the same way - you just need to read your checkbox or radio button to decide which of two hidden forms gets submitted.
Hope it works...
function setAction () {
if (document.formname.checkbox.checked) {
document.formname.action = 'http://www.domain.com/search/search.pl';
} else {
document.formname.action = 'http://www.domain.com/search/search.cgi';
}
}
something like that, I remember last time I used this having an issue but I can't really remember why. Try it and see. You could also have the action as a small script and have that send it to the right search script in case people have js turned off.