Avatar of kbtudor
Flag for United States of America

asked on 

Javascript wildcard?

This is from a swim meet registration form written in Coldfusion.  I have a control in place that makes sure at least one event has been select, but not more than three.   (The js script is further below).

I need multiple loops into a table.  Therefore, my code for this particular form field looks like this:

<input type="checkbox" name="eventsID#curRow#" id="eventsID" value="#getDayOne.eventsID#" />

This works as I need it to.  But in appending #curRow# to eventsID, my js no longer works.  Because I know very little about js, how do I go about writing it for contains or like  a wildcard is what Im looking for.

         if ((e.name LIKE 'eventsID') && (e.type=='checkbox'))
         if ((e.name CONTAINS 'eventsID') && (e.type=='checkbox'))
         if ((e.name == 'eventsID(%)') && (e.type=='checkbox'))

Thanks ahead of time for your help.


function checkCheck()
{ var counter=0;
    for (var i=0;i<document.frmswimMeet.elements.length;i++)
         var e = document.frmswimMeet.elements[i];
         if ((e.name == 'eventsID') && (e.type=='checkbox'))
              if ( e.checked )
                   counter = counter+1; }
    if (counter > 3)
         alert(' You can only select up to 3 events!');
       return false;   }
    else if (counter < 1)
         alert(' You did not select any events!');
         return false;   }
         return true;              

Avatar of undefined
Last Comment

8/22/2022 - Mon