Yeah the part in {} is too large.Actually I have about 160 checkboxes on my page,so what I need to do is to create a list of the values of checkboxes which are checked.So in my javascript I have something like this:
Job = Job + ',';
if (document.Jobs.J1.checked)
Job = Job + 162;
if (document.Jobs.J2.checked) if(Job != '')
Job = Job + ',';
if (document.Jobs.J3.checked)
Job =Job + 771;
*
*
* till
if (document.Jobs.J160.checked)
Job =Job + 771;
In the same manner I build up another list of ID's.
I am new to all this and it may seem a bit amateurish.But I am learning.So suggestions are welcome.
Can you split your if into several if/else's or switch statements? BTW, how large is too large? Does it specify in your error statement? Can you do a character count on you code?
Sincerely,
are the ref of the checkboxes (J1, ..., J160) somehow related to the values you add to "Job" ??
well even if they are not, you can give "J1" as a name and "162" as a value for the 1st checkbox
now you just loop thru all the checkboxes (document.form.elements[..]), and for each checkbox, if checked, add its value to 'job'
Should be working, let me know !!
I came across the same error message, and wondered if you had found a solution to it? Please let me know - The script I'm working on is for a DHTML/Javascript menu.
This is a summary of some earlier posts to this question:
function Checker() {
for (var i = 0; i < Jobs.elements.length; i++)
{
if (document.Jobs.elements.checked=="1"
Job = Job + musicForm.elements.value; + ";"
}
}
where "Jobs" is a form name and "Jobs.elements" - current checkbox item.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.