By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,903 Members | 1,647 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,903 IT Pros & Developers. It's quick & easy.

search depending on what user selects

P: n/a
what i want to do is create several radio buttons and a textbox for
searching purposes. the search will perform a search depending on
which button the user selects.

here is what i have now:

- for each radio button, i use the onClick event handler, which calls
a function called showMe()

- showMe() {
if (button 1 was selected)
document.write('form which will search down path A');
else if (button 2 was selected)
document.write('form which will search down path B');
else if (button 3 was selected)...
}

this works, but once the user makes their selection, the search form
will pop up on another page. how do i fix it so that the search form
will display on the same page as the radio buttons? Is there any
other way to accomplish this?
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
bdawg wrote:
what i want to do is create several radio buttons and a textbox for
searching purposes. the search will perform a search depending on
which button the user selects.

here is what i have now:

- for each radio button, i use the onClick event handler, which calls
a function called showMe()

- showMe() {
if (button 1 was selected)
document.write('form which will search down path A');
else if (button 2 was selected)
document.write('form which will search down path B');
else if (button 3 was selected)...
}

this works, but once the user makes their selection, the search form
will pop up on another page. how do i fix it so that the search form
will display on the same page as the radio buttons? Is there any
other way to accomplish this?


Hi,

What excactly do you expect javascript to do? Overwrite your old form? It
will not.
You CAN make a form on a existing page from scratch and change that form,
but that takes a lot more effort than just document.write, and is most of
the time completely unneeded and overcomplex. Of course, that depends on
your requirements.

I would advise you to take another route.
here are 2 suggestions:
1) Maybe it is a lot easier to make a frame which contains the form, and
switch the content in that frame depending on the radiobuttonactions.

2) If your only diffence between between the forms is some searchpath (I
don't know what that means), maybe it is a lot easier to set some hidden
variables in the form that tell the receiving script what to search.

Hope that helps.

Good luck.
Regards,
Erwin Moller

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.