<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2650.12">
<TITLE>RE: [Javascript] RegExp question</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>and what about</FONT>
<BR><FONT SIZE=2>tabvar = document.forms.name.split("_");</FONT>
<BR><FONT SIZE=2>so you get tabvar[1] and tabvar[2] with the values</FONT>
</P>
<P><FONT SIZE=2>-----Message d'origine-----</FONT>
<BR><FONT SIZE=2>De : Christopher Basken [<A HREF="mailto:chriz@basken.com">mailto:chriz@basken.com</A>]</FONT>
<BR><FONT SIZE=2>Envoyé : jeudi 13 décembre 2001 23:32</FONT>
<BR><FONT SIZE=2>À : javascript@LaTech.edu</FONT>
<BR><FONT SIZE=2>Objet : [Javascript] RegExp question</FONT>
</P>
<BR>
<P><FONT SIZE=2>Hi,</FONT>
</P>
<P><FONT SIZE=2>I've got a page with a bunch of form elements on it. A bunch of elements</FONT>
<BR><FONT SIZE=2>are named "course_01_02" or "course_12_01" and so on. I want to loop</FONT>
<BR><FONT SIZE=2>through them and yank out the values of these elements, but since I also</FONT>
<BR><FONT SIZE=2>need to know the digits, I need to match the numbers (not just the beginning</FONT>
<BR><FONT SIZE=2>"course").</FONT>
</P>
<P><FONT SIZE=2>I've got this function:</FONT>
</P>
<P><FONT SIZE=2>function FormValidation(theForm) {</FONT>
</P>
<P><FONT SIZE=2> for (var i = 0; i < theForm.length; i++) {</FONT>
<BR><FONT SIZE=2> var e = theForm.elements[i].name;</FONT>
<BR><FONT SIZE=2> var pattern = new RegExp("course_(\d+)_\d+","ig");</FONT>
<BR><FONT SIZE=2> alert(e.match(pattern)); // test</FONT>
<BR><FONT SIZE=2> }</FONT>
</P>
<P><FONT SIZE=2>}</FONT>
</P>
<P><FONT SIZE=2>But it keeps coming up Null. According to the documentation at</FONT>
<BR><FONT SIZE=2>developer.netscape.com, this should work.</FONT>
</P>
<P><FONT SIZE=2>Any thoughts?</FONT>
</P>
<P><FONT SIZE=2>Thanks!</FONT>
</P>
<P><FONT SIZE=2>Chris</FONT>
</P>
<BR>
<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>Javascript mailing list</FONT>
<BR><FONT SIZE=2>Javascript@LaTech.edu</FONT>
<BR><FONT SIZE=2><A HREF="https://lists.LaTech.edu/mailman/listinfo/javascript" TARGET="_blank">https://lists.LaTech.edu/mailman/listinfo/javascript</A></FONT>
</P>
</BODY>
</HTML>