473,398 Members | 2,404 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,398 software developers and data experts.

Checking One Box when I check a second checkbox

I have a form with 2 check boxes. One of the check boxes is used to
specify that the user is a "primary contact." When I check the
primary contact box I want a second box for "standard contact" to be
checked as all primary contacts must be standard contacts. If I
uncheck the primary contact no change in status of the standard
contact is needed. I am assuming I can use some onclick function but
I tried using a onclick on the one box to check the second. The code
I used onClick="document.form2.BCPContact.checked=true" I was hoping
this would check the second box anytime I clicked the first. I
realize this doesnt do exactly what I ask but I couldnt even get that
part working. Is there a problem in my syntax?

How can I modify this form to check the Standard contact button when I
check the primary box?
<form method="POST" action="<%=MM_editAction%>" name="form1">
<input name="StandardContact" type="checkbox" value=1 <%If
(CStr(rsUsers.Fields.Item("StandardContact").Value ) = CStr("True"))
Then Response.Write("checked") : Response.Write("")%>>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%=
rsUsers.Fields.Item("UserId").Value %>">

<input type="checkbox" name="PrimaryContact" value=1 <%If
(CStr(rsUsers.Fields.Item("Primary").Value) = CStr("True")) Then
Response.Write("checked") : Response.Write("")%>>
Jul 23 '05 #1
3 2727
Lee
Rich said:
How can I modify this form to check the Standard contact button when I
check the primary box?


When the PrimaryContact checkbox is clicked, you want to
set the value of StandardContact.checked to be true if it
was already true, or if PrimaryContact is now checked.

Since the two controls are in the same form, you can refer
to the form that contains them both as "this.form".

So what you want is to set the onclick attribute of the
PrimaryContact checkbox to:

onclick="this.form.StandardContact.checked|=this.c hecked"

Jul 23 '05 #2
This worked great great I used

<input type="checkbox" name="PrimaryContact"
onclick="this.form.StandardContact.checked|=this.c hecked"

and it checks the StandardContact if I check the primary. I am trying to
create a second version of the script so that it unchecks the primary if I
uncheck the secondary.

The closested on got was:
<input type="checkbox" name="StandardContact"
onclick="this.form.PrimaryContact.checked|=this.ch ecked==false" >

This code checks the PrimaryContact box when I uncheck the StandardContact
Box. The problem is that I want to uncheck. I tried modifying the code to
<input type="checkbox" name="StandardContact"
onclick="this.form.PrimaryContact.checked==false|= this.checked==false" >
and
<input type="checkbox" name="StandardContact"
onclick="this.form.PrimaryContact.unchecked|=this. checked==false" >

However no matter what I do I cant modify the first part so that the
PrimaryContact state is set to unchecked when the standard is unchecked. Is
that modifiction possible with the code I was given?


"Lee" <RE**************@cox.net> wrote in message
news:c8********@drn.newsguy.com...
Rich said:
How can I modify this form to check the Standard contact button when I
check the primary box?


When the PrimaryContact checkbox is clicked, you want to
set the value of StandardContact.checked to be true if it
was already true, or if PrimaryContact is now checked.

Since the two controls are in the same form, you can refer
to the form that contains them both as "this.form".

So what you want is to set the onclick attribute of the
PrimaryContact checkbox to:

onclick="this.form.StandardContact.checked|=this.c hecked"

Jul 23 '05 #3
Lee
Woody said:

This worked great great I used

<input type="checkbox" name="PrimaryContact"
onclick="this.form.StandardContact.checked|=this. checked"

and it checks the StandardContact if I check the primary. I am trying to
create a second version of the script so that it unchecks the primary if I
uncheck the secondary.

The closested on got was:
<input type="checkbox" name="StandardContact"
onclick="this.form.PrimaryContact.checked|=this.c hecked==false" >

This code checks the PrimaryContact box when I uncheck the StandardContact
Box. The problem is that I want to uncheck. I tried modifying the code to
<input type="checkbox" name="StandardContact"
onclick="this.form.PrimaryContact.checked==false| =this.checked==false" >
and
<input type="checkbox" name="StandardContact"
onclick="this.form.PrimaryContact.unchecked|=this .checked==false" >

However no matter what I do I cant modify the first part so that the
PrimaryContact state is set to unchecked when the standard is unchecked. Is
that modifiction possible with the code I was given?
You need a slightly more complicated form for that case.
You don't use |= because the new state of PrimaryContact
doesn't depend on its previous state. You don't want to
change the state at all unless this.checked is false, and
in that case, you always want to set StandardContact to
be unchecked:

<input type="checkbox" name="StandardContact"onclick="if(!this.checked)this.form.PrimaryContac t.checked=false">


Jul 23 '05 #4

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

Similar topics

3
by: Wendy S | last post by:
I have this working, but I don't think it's done efficiently or the best way: <a href="javascript:setAllAccounts(true)">check all</a> <a href="javascript:setAllAccounts(false)">clear all</a> ...
3
by: Jack | last post by:
Hi, I have a form when loaded, retrieves record from an access table. Among other fields there is a check box called FinalUpdate. This is tied to a field in Access of type Yes/No. The form...
0
by: D. Shane Fowlkes | last post by:
OK - I'm looking for the best approach on how to do this. I have a form page where the user can edit their "Profile" (data) which is in SQL Server. It's your basic company information - address,...
0
by: D. Shane Fowlkes | last post by:
OK - I'm looking for the best approach on how to do this. I have a form page where the user can edit their "Profile" (data) which is in SQL Server. It's your basic company information - address,...
0
by: dolberg | last post by:
Hi, I have a Treeview containing groups and groupmembers and I would like to have the childnodes (groupmembers) checked when checking a parent node (a group). This is no problem using the...
1
by: Ramakrishnan Nagarajan | last post by:
Hi, I have two checkboxes in each row of a grid. One for Modify and another one for View. If I click Modify the View should get automatically checked and should be disabled. Earlier I did this in...
0
by: arunesh | last post by:
hi all I am writing an ASP.NET application using VB.NET as the code behind file. I have put a repeater control on an aspx page which is filled in from a dataset. each row of this repeater has...
1
by: Kevin R | last post by:
This is one of the weirdest problems I have ever run into. I have had to trim down a bunch of code to give a sample that is more easily readable by those who will view this. Here is the problem:...
2
by: uoziod | last post by:
Hello. Sorry for my english :) I got a next problem. This is a HTML. <ul> <li id="cat3"><input type="checkbox" onChange="javascript:groupCatCheck('3', this)" name="categories" value="3"...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
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.