473,779 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Checkbox Help Needed

I have a function that I call to check or uncheck all checkboxes on a
form - I use a 'master' checkbox to do this much like hotmail has to
check all mail messages - the code works fine if I name my checkboxes
like this:
chk1
chk1
chk1

But I need to name them with an array for deletion purposes which is
already coded and working - I need to name them like this:
chk[0]
chk[1]
chk[2]

I can't get the check/uncheck function to work with array checkbox
names - at the bottom of this I show my main checkbox I use to check
or uncheck all the others checkboxes named chk1 - but how do I pass
the name of the array checkboxes???
<!-- Hide javascript code
function check_checkboxe s(pObj, pFlag)
{
if (pObj.length) {
for (var iCount=0; iCount<pObj.len gth; iCount++)
pObj [ iCount ].checked = pFlag;
}
else {
pObj.checked = pFlag;
}
}
// stop hiding javascript -->
</SCRIPT>

<INPUT TYPE="checkbox" NAME="frm_check _all"
onClick="check_ checkboxes(docu ment.pmsgs_form .chk1,
frm_check_all.c hecked)">Check/UnCheck All</TD>
Jul 20 '05 #1
2 8339

"Ralph Freshour" <ra***@primemai l.com> schreef in bericht
news:dp******** *************** *********@4ax.c om...

But I need to name them with an array for deletion purposes which is
already coded and working - I need to name them like this:
chk[0]
chk[1]
chk[2]

I can't get the check/uncheck function to work with array checkbox
names - at the bottom of this I show my main checkbox I use to check
or uncheck all the others checkboxes named chk1 - but how do I pass
the name of the array checkboxes???


<script type="text/javascript">
function check_checkboxe s(pForm, pObj, pFlag) {
for (var iCount=0;;iCoun t++) {
if (!pForm.element s[pObj + iCount]) break;
pForm.elements[pObj + iCount ].checked = pFlag;
}
}
</script>

<form>
<input type="checkbox" name="chk0"><br />
<input type="checkbox" name="chk1"><br />
<input type="checkbox" name="chk2"><br />
<input type="checkbox" name="frm_check _all"
onclick="check_ checkboxes(form ,'chk',checked) ">Check/UnCheck All
</form>
JW

Jul 20 '05 #2

"Janwillem Borleffs" <jw@jwscripts.c om> schreef in bericht
news:3f******** *************** @news.euronet.n l...

But I need to name them with an array for deletion purposes which is
already coded and working - I need to name them like this:
chk[0]
chk[1]
chk[2]


Just realised that my previous solution did not work with PHP-array style
element names, the following does:

<script type="text/javascript">
function check_checkboxe s(pForm, pObj, pFlag) {
var elem;
for (var iCount=0;;iCoun t++) {
elem = pObj + '[' + iCount + ']';
if (!pForm.element s[elem]) break;
pForm.elements[elem].checked = pFlag;
}
}
</script>

<form>
<input type="checkbox" name="chk[0]"><br />
<input type="checkbox" name="chk[1]"><br />
<input type="checkbox" name="chk[2]"><br />
<input type="checkbox" name="frm_check _all"
onclick="check_ checkboxes(form ,'chk',checked) ">Check/UnCheck All
</form>

Also, have a look at the FAQ entry regarding this subject:

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

Jul 20 '05 #3

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

Similar topics

5
8128
by: Ralph Freshour | last post by:
I'm using MySQL to display data on a web page - fitting about 10 records of data per screen - I'm including a checkbox with each record so that I can check it and when the submit button is clicked the called .php script will delete those records that are checked. I'm creating the records from the table with the checkboxes ok (I think): <INPUT TYPE='checkbox' NAME='frm_chk_delete'>Delete
3
1898
by: Voetleuce en f?nsievry | last post by:
G'day I'm looking for a script that can search multiple instances of Google (or other search engines optionally). The user types in a single word in the text field, presses ENTER or the submit button, and the browser launches several instances of Google with the single word + other search terms. I would like to have this script because I'm a translator and frequently need to look up the meaning of words. I Google using
8
2842
by: Ralph Freshour | last post by:
I have multiple checkbox's created with an array name because I have many on the same web page - their names are like: frm_chk_delete frm_chk_delete frm_chk_delete frm_chk_delete etc. Here is my code line that creates each checkbox (the php variable get
2
1960
by: TonyM | last post by:
Hi Guys, I just need a push in the right direction here, I'm kinda stuck. I have a project with multiple Windows Forms launching from the main form by use of checkboxes. very easy, got that handled. The problem I have is this: If the "cancel" button is pressed on one of the spawned forms I can close that form, but I need to uncheck the checkbox on that was originally checked.
0
3121
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td colspan="2"><p>
11
15296
by: TechnoAtif | last post by:
INSERT AND UPDATE MULTIPLE CHECKBOX DATA USING PHPMYSQL OR JAVASCRIPT Hi All I want to check the multiple checkboxes update them after revisiting that page. I am taking the name as name=type..in the form of array..but on checking it the result in the database simply gives the world 'array'.i want multiple checkboxes to be checked and updated simultaneously.. and the query to insert the checkbox value has to be included along with...
25
5403
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. Basically i have a multiple select box. An it works except for this one part i want to add to it.The first box i have is called project members which shows the users you can choose to send an email to and the other box is called assignees which is the...
58
8126
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also the parts section an i seem to be having trouble. When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections...
482
28025
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. what i am trying to display previously entered multiple fields. I am able to get my serial fields to display correctly, but i can not display my parts fields correctly. Currently this is what it does serial information 1 parts 1
0
10302
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8958
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.