Multiple Search Options - Radio Buttons Instead Of Drop Down List

In summary, the conversation discusses a tutorial on creating a search form with multiple options. The tutorial is highly recommended, but the person asks if it is possible to use radio buttons instead of a drop-down list. Someone offers a code example using radio buttons to search on different search engines.
  • #1
jleung
3
0
The tutorial on how to make a search form with multiple search options was excellent!

http://www.mediacollege.com/internet/javascript/form/multi-search.html

However, is it possible to use radio buttons instead of a drop-down list?Can someone be kind enough to show me the code for it?

Million thanks.
 
Technology news on Phys.org
  • #2
You can do for example:
Code:
<html>
<body>
    <script language="JavaScript">eng = 'http://www.google.com/search?q=';</script>  
    For: 
    <input type="text" id="searchterms">
    <input type="button" value="Search" onload="" onclick="window.location = eng + escape(document.getElementById('searchterms').value); return false;">
    <br />Search: 
    <input type="radio" onclick="eng = this.value;" checked name="sengines" value="http://www.google.com/search?q=" />Google
    <input type="radio" onclick="eng = this.value;" name="sengines" value="http://www.altavista.com/web/results?q=" />Alta Vista
    <input type="radio" onclick="eng = this.value;" name="sengines" value="[PLAIN]http://www.dogpile.com/info.dogpl/search/web/"[/PLAIN]  />Dogpile
    <input type="radio" onclick="eng = this.value;" name="sengines" value="http://search.yahoo.com/search?p=" />Yahoo!    
</body>
</html>
 
Last edited by a moderator:
  • #3


Thank you for your feedback on the tutorial. I'm glad you found it helpful! As for your question about using radio buttons instead of a drop-down list, it is definitely possible and can be a great alternative for a search form. Here is a code snippet that you can use to implement radio buttons in your search form:

<form>
<input type="radio" name="searchOption" value="option1">Option 1<br>
<input type="radio" name="searchOption" value="option2">Option 2<br>
<input type="radio" name="searchOption" value="option3">Option 3
</form>

You can add more options by simply adding more <input> tags with different values for the "value" attribute. Then, in your JavaScript code, you can access the selected option by using the "value" property of the selected radio button. I hope this helps! Let me know if you have any further questions. Happy coding!
 

1. How do radio buttons differ from a drop-down list in multiple search options?

Radio buttons allow for selecting only one option at a time, while a drop-down list allows for selecting multiple options.

2. How are radio buttons more user-friendly in multiple search options?

Radio buttons are more visually appealing and easier to navigate for users, as they can clearly see all available options and easily select their desired choice.

3. Can radio buttons be used for more than just text options in multiple search options?

Yes, radio buttons can be used for different types of data such as numbers, dates, and images in multiple search options.

4. Are radio buttons the most efficient way to display multiple search options?

It depends on the specific use case and the user's preferences. Some users may find drop-down lists to be more efficient, while others may prefer radio buttons.

5. Is it possible to combine radio buttons and drop-down lists in multiple search options?

Yes, it is possible to have a combination of both radio buttons and drop-down lists in multiple search options, depending on the needs of the user and the available options.

Similar threads

  • Programming and Computer Science
Replies
15
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • STEM Career Guidance
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
Replies
4
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Sci-Fi Writing and World Building
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
265
  • General Discussion
Replies
4
Views
652
Back
Top