search depending on what user selects

B

bdawg

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?
 
E

Erwin Moller

bdawg said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top