473,396 Members | 1,996 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.

Make checkboxes work like radio buttons but...

Here's a working code fragment out of a form.
One checkbox is checked the other isn't.
When you change the status of one the other changes too.

<input type="checkbox" name="nlbox1" value="9" checked
onClick="document.signup.nlbox2.checked=!document. signup.nlbox2.checked;">

<input type="checkbox" name="nlbox2" value="8"
onClick="document.signup.nlbox1.checked=!document. signup.nlbox1.checked;">

OK now the problem (and I expect you are asking, why not just use
radio buttons?)

The form gets sent to someone else's script on a server I can't
modify. Their version of the form looked like this:

<input type="checkbox" name="nlbox[1]" value="9" >
<input type="checkbox" name="nlbox[2]" value="8">

That allowed neither or both boxes to be checked. The problem is if I
try to use:

<input type="checkbox" name="nlbox[1]" value="9" checked
onClick="document.signup.nlbox[2].checked=!document.signup.nlbox[2].checked;">

<input type="checkbox" name="nlbox[2]" value="8"
onClick="document.signup.nlbox[1].checked=!document.signup.nlbox[1].checked;">

I get an error. Mozilla says:
document.signup.nlbox has no properties

MSIE says:
document.signup.nlbox.1 is null or not an object

Any ideas?

Incidentally
<input type="radio" name="nlbox[1]" value="9" >
<input type="radio" name="nlbox[2]" value="8">
won't work because as the name differs they don't operate as a pair.

Jul 23 '05 #1
3 5520
Lee
sh******************@spam.hairdresser.net said:
The problem is if I try to use:

<input type="checkbox" name="nlbox[1]" value="9" checked
onClick="document.signup.nlbox[2].checked=!document.signup.nlbox[2].checked;">

<input type="checkbox" name="nlbox[2]" value="8"
onClick="document.signup.nlbox[1].checked=!document.signup.nlbox[1].checked;">

I get an error. Mozilla says:
document.signup.nlbox has no properties

MSIE says:
document.signup.nlbox.1 is null or not an object

Any ideas?

http://www.jibbering.com/faq/#FAQ4_25

Jul 23 '05 #2
Rob
On 23 Jun 2004 13:31:31 -0700, Lee <RE**************@cox.net> wrote:

MSIE says:
document.signup.nlbox.1 is null or not an object

Any ideas?

http://www.jibbering.com/faq/#FAQ4_25


Excellent, thanks it works just fine now.

I'll just go and write out 100 times "ALWAYS check the FAQ first!"

Jul 23 '05 #3
Rob <pu*********@sheffield.port995.com> writes:
I'll just go and write out 100 times "ALWAYS check the FAQ first!"


for (var i = 0; i < 100; i++) {
document.write("<p>ALWAYS check the FAQ first!<\/p>");
}

/L ':P'
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Newbie | last post by:
I currently have a set of simple calculations to determine square footage and multuply that by a dollar amount per foot. I use form fields that are filled in by the user, and then the Submit...
9
by: Gary | last post by:
Hello, Is it possible to dynamically update a textbox with words chosen from a list using form checkboxes and javascript? Gary
2
by: Glenn | last post by:
The following script is supposed to have high categories as radio buttons and mid categories as check boxes. Clicking the radio button is supposed to select all checkboxes under it and submit the...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
11
by: shree | last post by:
Hello everyone, I'm writing a form which will have a group of checkboxes. When user selects one checkbox, it will automatically disable the rest of the checkboxes in the group. I'm able to...
8
by: Chuck W. | last post by:
Is there a way with javascript to make a series of checkboxes behave like radio buttons, such that if someone attempts to check more than one, they would get a pop-up alert "can't do that" ? ...
4
by: jeet | last post by:
Plz help me.Problem is that On the first page I display all other user with checkbox and give user option to select only two user which he wants to send message. Tell me please how I'll get those...
2
by: forbes | last post by:
Hi, I have a form that contains multiple groups of checkboxes that act like radio buttons (at the clients insistance). There is one text field that is required and 28 checkbox groups. Here an...
2
by: BillE | last post by:
Users of a VS2005 asp.net web forms application can complete questionnaires, and when they are completed the questionnaires can be viewed but not modified. Once completed, the controls in the...
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
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
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
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.