Why is this loop choking? (Prototype.js)
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Steve_Y
Posted On:   Tuesday, August 8, 2006 02:38 PM

The below script loops through a list of form elements and, when it finds one that it suspects to be a Date or an SSN, applies calls the autojump function. Problem: its only making it through the first loop, No Matter What. I suspect I dimly understand the powers of .each Please edify me. ----- $A(form.elements).each(function(x){ if(x.type != undefined){ if(x.id!="" && x.type == "text"){ if(ereg("MM",x.id)) { group = x.id.split("MM"); group = group[0]; autojump(group + "MM", group + "DD",2,form); autojump(group + "DD", group + &   More>>

The below script loops through a list of form elements and, when it finds one that it suspects to be a Date or an SSN, applies calls the autojump function.

Problem: its only making it through the first loop, No Matter What.

I suspect I dimly understand the powers of .each

Please edify me.

-----

			
$A(form.elements).each(function(x){
if(x.type != undefined){
if(x.id!="" && x.type == "text"){
if(ereg("MM",x.id)) {
group = x.id.split("MM");
group = group[0];
autojump(group + "MM", group + "DD",2,form);
autojump(group + "DD", group + "YYYY",2,form);
} else if(x.id=="SSN1"){
autojump('SSN1','SSN2',3,form);
autojump('SSN2','SSN3',2,form);
}
}
}
});
   <<Less

Re: Why is this loop choking? (Prototype.js)

Posted By:   Steve_Y  
Posted On:   Tuesday, August 8, 2006 04:08 PM

Solved.

ereg was strangely to blame.

I used indexOf > 0 instead.
About | Sitemap | Contact