473,396 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Adjust JavaScript for radio buttons replaced with dropdown select

229 100+
Hi, I want to replace the input type="radio" with a dropdown <select>. I wonder if anyone could tell me how to adjust the javascript. I have tried replacing "checked" with "select" but it didnt work.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  5. <title>Name</title><script src="/js/validatesearch.js" type="text/javascript"></script>
  6. </head>
  7.  
  8. <body>
  9. <script type="text/javascript" language="JavaScript">
  10. <!-- Copyright 2003 Bontrager Connection, LLC
  11. // See article "Changing Form Action URLs On-The-Fly" linked 
  12. // from URL /library/archives 
  13. // for more information about how to use this code.
  14. function ActionDeterminator()
  15. {
  16. if(document.myform.reason[0].checked == true) {
  17. document.myform.action = '/search.asp';
  18. }
  19. if(document.myform.reason[1].checked == true) {
  20. document.myform.action = '/businesssearch.asp';
  21. }
  22. if(document.myform.reason[2].checked == true) {
  23. document.myform.action = 'artschoolsearch.asp';
  24. }
  25. return true;
  26. }
  27. // -->
  28. </script>
  29.  
  30. <form name="myform" method="post" action="search.asp" onsubmit="return validate_form(this)">
  31.  
  32. <input type="text" size="12" name="SearchWord" style="border: 0px solid #000; padding: 0px; background-color: #c0c0c0; margin-left: 0px; margin-right: 0px; vertical-align: middle;">
  33. <input onClick="return ActionDeterminator();" value="search" type="submit" style="border: 0px solid #000; padding: 1px 2px; background-color: #808080;margin-left: 1px;  vertical-align: middle; font-size: 10px; font-family: Verdana;" >
  34.  
  35.  
  36. <input type="radio" checked name="reason">art
  37. <input type="radio" name="reason">business
  38. <input type="radio" name="reason">tips
  39.  
  40.  
  41. </form>
  42. </body>
  43.  
  44. </html>
so swap the select for something like this.


Expand|Select|Wrap|Line Numbers
  1. <select>
  2. <option selected>please select</option>
  3. <OPTION>----------------------------------</Option>
  4. <option>art</option>
  5. <option>business</option>
  6. <option>tips</option>
  7. </select>

Any help would be great.
Thanks
Richard
Aug 14 '08 #1
3 1784
acoder
16,027 Expert Mod 8TB
Add values to the options set as the URL to set the action to, then change ActionDeterminator to something like:
Expand|Select|Wrap|Line Numbers
  1. function ActionDeterminator()
  2. {
  3.     var val = document.myform.reason.value;
  4.     if (val != "") {
  5.         document.myform.action = val;
  6.     }
  7.     return true;
  8. }
PS. changed thread title to give it a better description.
Aug 14 '08 #2
fran7
229 100+
thanks a lot
richard
Aug 14 '08 #3
acoder
16,027 Expert Mod 8TB
You're welcome. Glad it's working :)
Aug 14 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
2
by: James Gardner | last post by:
Within a single form I have a dropdown select box with 2 options and 2 radio buttons. If someone selects option 2 in the dropdown I would like to make the radio buttons disabled, such that you...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.