473,395 Members | 1,456 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,395 software developers and data experts.

Array help!!

Hi,
Please help. Here is the situation. I've tried to create a radio button
when clickeck by a user, a function will automatically check all
checkbox in a form. I've tried to do this using a for loop but I did
not have any luck.

My intention was when a user click on the radio button, checkbox for
testa,testb,testc,and testd will be checked.

<form name="myForm">
check all<input type="radio" name=alert value=all
onclick="checkAll(this)">
<font color="oliveDrab" size=1%>testa </font><input
type="checkbox" name=aix64testd value=aix64testd>
<font color="oliveDrab" size=1%>presto </font><input
type="checkbox" name=aix64testa value=aix64testa>
<font color="oliveDrab" size=1%>psyn </font><input
type="checkbox" name=aix64testb value=aix64testb>
<font color="oliveDrab" size=1%>psynim </font><input
type="checkbox" name=aix64testc value=aix64testc>

<script type="text/javascript">

function checkAll(Array1) {
var myArr = new
Array('aixtestd','aix64testa','aix64testb','aix64t estc');
for(var i; i<myArr.length;i++) {
document.myForm.myArr['+i+']=true;
}
}
<script>

Thx, -Christie

Jul 23 '05 #1
2 1070
In article <11*********************@g14g2000cwa.googlegroups. com>, kenvin007
@yahoo.com enlightened us with...
Hi,
My intention was when a user click on the radio button, checkbox for
testa,testb,testc,and testd will be checked.

<form name="myForm">
check all<input type="radio" name=alert value=all
onclick="checkAll(this)">
Why are you sending the object to the function? It is not needed the way it
is coded.
<script type="text/javascript">

function checkAll(Array1)
You never reference Array1. If this is the full code, you can remove it.
Don't forget that if you remove it from the call, you need to remove it from
the function and vice versa.

{ var myArr = new
Array('aixtestd','aix64testa','aix64testb','aix64t estc');
for(var i; i<myArr.length;i++) {
document.myForm.myArr['+i+']=true;


document.myForm.elements[myArr[i]].checked = true;

Try that.
Oh, and put attributes (like names and ids) in quotes. It can save a headache
later if you do odd things like use brackets, spaces, or start the attributes
with a number. i.e. checkbox name="aix64testa"

Note: this is not at all how I'd code this sort of thing, but hey. :)

--
--
~kaeli~
The more ridiculous a belief system, the higher probability
of its success.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

kaeli wrote:
In article <11*********************@g14g2000cwa.googlegroups. com>, kenvin007 @yahoo.com enlightened us with...
Hi,
My intention was when a user click on the radio button, checkbox for testa,testb,testc,and testd will be checked.

<form name="myForm">
check all<input type="radio" name=alert value=all
onclick="checkAll(this)">
Why are you sending the object to the function? It is not needed the

way it is coded.
<script type="text/javascript">

function checkAll(Array1)
You never reference Array1. If this is the full code, you can remove

it. Don't forget that if you remove it from the call, you need to remove it from the function and vice versa.

{
var myArr = new
Array('aixtestd','aix64testa','aix64testb','aix64t estc');
for(var i; i<myArr.length;i++) {
document.myForm.myArr['+i+']=true;
document.myForm.elements[myArr[i]].checked = true;

Try that.
Oh, and put attributes (like names and ids) in quotes. It can save a

headache later if you do odd things like use brackets, spaces, or start the attributes with a number. i.e. checkbox name="aix64testa"

Note: this is not at all how I'd code this sort of thing, but hey. :)
--
--
~kaeli~
The more ridiculous a belief system, the higher probability
of its success.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


Jul 23 '05 #3

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

Similar topics

2
by: JackM | last post by:
Let me attempt to explain my problem. I have a crude php script that takes a text list of songs that was generated by an mp3 list program and translates each entry into the form where they can be...
5
by: ali | last post by:
Hi, I'm trying to understand the reason for different output on the following codes Code1: #include <iostream.h> int main()
1
by: aemazing | last post by:
hello, im new to the forum and i wanted to help with my c++ program. the teacher wants us to design a progrm that would keep track of airplanes awaitin landing at an airport. the program will...
1
by: aemazing | last post by:
i've been tryin to do the following - -Add a new flight number to the end of the queue (got it done) -LAnd the plane at the front of the queue - problems wit it- -display the queue - got it done...
5
by: ritchie | last post by:
Hi, I am writing to ask if anyone can see why my array is not being sorted correctly? It's an array of 4 elements(ints 1,2,3,4) but after calling the selection sort it comes back sorted as...
3
by: d4m | last post by:
I have the following which works okay... Dim arrayTable As Variant Dim varTable As Variant arrayTable = Array("SG", "Oakland", "Server") For Each varTable In arrayTable SQL1 = "INSERT...
3
by: clawton | last post by:
Hi All - I've got a 3rd party COM object that returns an array of bytes that are a TIFF image. After adding the reference to the com object to my solution the C# signature for the method is...
3
by: kurrent | last post by:
i'm still new to php and programming and was hoping to get some help on a few questions i haven't had success in answering myself. I successfully created my first very simple script to accomplish a...
5
by: Stephen3776 | last post by:
I am doing an inventory control progam and trying to output a multiple array, I am getting an illegal conversion error java.lang.double !d. Can somebody tell me what I am doing wrong or if there is...
1
by: comedydave | last post by:
Hi guys, I'm new to ASP and need some array help. I need to have a shopping cart. When you visit the site it creates a session and an array. When you click add to basket it adds the item ID to...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...

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.