Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript Error: if statement too large

Status
Not open for further replies.

Progmatic

Programmer
Oct 17, 2000
33
CA
I am getting an error in netscape
JavaScript Error: if statement too large

and it ceases the link(link doesn't work) which uses the javascript function.

Help
Thx
 
can you please post the applicable code? I've never seen that before. jared@aauser.com
 
never seen that either ! can't you split your if statement ?
 
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.

Advice.

thx


 
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,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
you can loop through all the forms elements and test that way. jared@aauser.com
 
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.

daniel.greenlee@baesystems.com

Thanks.

Take care,

Daniel.
 
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==&quot;1&quot;)
Job = Job + musicForm.elements.value; + &quot;;&quot;
}
}
where &quot;Jobs&quot; is a form name and &quot;Jobs.elements&quot; - current checkbox item.

Andrew | starway@mail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top