473,396 Members | 2,052 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.

Automatically select a radio button if a checkbox is selected.

2
I have a form with 2 radio buttons and multiple checkboxes (see example below). The one radio button indicates all and the other radio button indicates the user has chosen specific options (checkboxes) from a list. Can I use javascript to automatically select the 2nd radio button if the users clicks on any of the checkboxes?

<form name=form1>
<input type=radio name=Radio1 value=All>
<input type=radio name=Radio1 value=Specific>
<input type=checkbox name=Checkbox1>
<input type=checkbox name=Checkbox2>
<input type=checkbox name=Checkbox3>
<input type=checkbox name=Checkbox4>
</form>
Mar 10 '08 #1
3 2760
rnd me
427 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. <form name=form1>
  2.     <input type=radio name=Radio1 value=All tabindex=1>
  3.     <input type=radio name=Radio1 value=Specific>
  4.     <input type=checkbox name=Checkbox1 onclick='sel2()'>
  5.     <input type=checkbox name=Checkbox2 onclick='sel2()'>
  6.     <input type=checkbox name=Checkbox3 onclick='sel2()'>
  7.     <input type=checkbox name=Checkbox4 onclick='sel2()'>
  8. </form>
  9.  
  10.  
  11. <script type='text/javascript'>
  12.     function sel2(){document.forms['form1'].elements['Radio1'][1].focus()
  13. }
  14. </script>    

this will not always work in ie, as it allows only the first radio input of a group to be focused via js, when nothing else is selected...
Mar 10 '08 #2
vee10
141 100+
Hi ,

This may solve ur problem

Expand|Select|Wrap|Line Numbers
  1. <html xmlns="http://www.w3.org/1999/xhtml" >
  2. <head runat="server">
  3.     <title>Untitled Page</title>
  4.     <script type='text/javascript'>
  5.     function sel2()
  6.     {
  7.  
  8.    document.form1.Radio1[1].checked = true;
  9. }
  10. </script>
  11. </head>
  12. <body>        
  13.     <form name="form1" action="" >
  14.     <input type="radio" name="Radio1" value="All" tabindex="1" />
  15.     <input type="radio" name="Radio1" value="Specific" />
  16.     <input type="checkbox" name="Checkbox1" onclick='sel2()' />
  17.     <input type="checkbox" name="Checkbox2" onclick='sel2()' />
  18.     <input type="checkbox" name="Checkbox3" onclick='sel2()' />
  19.     <input type="checkbox" name="Checkbox4" onclick='sel2()' />
  20. </form>
  21. </body>
  22. </html>
  23.  
  24.  


I have a form with 2 radio buttons and multiple checkboxes (see example below). The one radio button indicates all and the other radio button indicates the user has chosen specific options (checkboxes) from a list. Can I use javascript to automatically select the 2nd radio button if the users clicks on any of the checkboxes?

<form name=form1>
<input type=radio name=Radio1 value=All>
<input type=radio name=Radio1 value=Specific>
<input type=checkbox name=Checkbox1>
<input type=checkbox name=Checkbox2>
<input type=checkbox name=Checkbox3>
<input type=checkbox name=Checkbox4>
</form>
Mar 11 '08 #3
camdev
2
Thank you. That's what I needed.

Hi ,

This may solve ur problem

Expand|Select|Wrap|Line Numbers
  1. <html xmlns="http://www.w3.org/1999/xhtml" >
  2. <head runat="server">
  3.     <title>Untitled Page</title>
  4.     <script type='text/javascript'>
  5.     function sel2()
  6.     {
  7.  
  8.    document.form1.Radio1[1].checked = true;
  9. }
  10. </script>
  11. </head>
  12. <body>        
  13.     <form name="form1" action="" >
  14.     <input type="radio" name="Radio1" value="All" tabindex="1" />
  15.     <input type="radio" name="Radio1" value="Specific" />
  16.     <input type="checkbox" name="Checkbox1" onclick='sel2()' />
  17.     <input type="checkbox" name="Checkbox2" onclick='sel2()' />
  18.     <input type="checkbox" name="Checkbox3" onclick='sel2()' />
  19.     <input type="checkbox" name="Checkbox4" onclick='sel2()' />
  20. </form>
  21. </body>
  22. </html>
  23.  
  24.  
Mar 11 '08 #4

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

Similar topics

3
by: ewitkop90 | last post by:
Here is my code: <SCRIPT> function transportchange(transport) { if (framenewinstall.Helpdesk.checked) framenewinstall.Helpdesk.checked=false; if (framenewinstall.CircuitNumber.checked)...
5
by: Samy | last post by:
Hi There, I have a label in a datagrid which I make it a input type = radio in ItemDataBound so that radio buttons are shown in the datagrid. This is how I have it... ASPX... <asp:Label...
1
by: jw01 | last post by:
Im trying to write a java script in HTML in which when a particular radio button is selected, a textbox would appear write next to the selected item. e.g (RADIO BUTTON) fhd: (RADIO BUTTON) fdj:...
1
by: Jerim79 | last post by:
I have a simple 3 page registration form. One form, one "data validation" script and one "insert into database" script. The customer bounces back and forth from the form to the verification script...
2
by: jw01 | last post by:
I changed my code...Now everytime i click a radio button, a text box appears...What i want is when i hit a particular radio button, the textbox should only appear next to that radio button. And if...
2
by: newfie912 | last post by:
I have an online application used for grading students. On one of the pages, I have a table with two rows and each row has 16 cells. The upper row contains the letter grade (A, A-, B+, B, etc)...
2
by: xoinki | last post by:
hi all, I am just trying to identify which radio button is selected in JS. although the code in totality does not make any sense since this is just a sample. it is not able to identify the 's' name...
3
by: kiranbabu | last post by:
<html> <head> <h2 align=center>Blank Tapes Status Form</h2> <br><title>Blank tapes status</title> </head> <body> <br><br> <form name=tapes_status method=post>
2
by: genkidave | last post by:
Hi there, I have three combo boxes that I would like to have Disabled (grayed out???) and preselected to a particular selection until a radio button (YES) is clicked, thus enabling the combo...
1
by: Izzy123 | last post by:
how do we auto selected a radio button when the user enters a numeric value in a textbox? my code for radio button and text box are as follows: <li>Do you like your membership priviledge? ...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.