|
Hi all members,
I am a new programmer for web development. I am creating a form that have attandence records which have fix number of column but dynamic rows.
There are four column have different radio buttons. having different name. I have one counter that is keep track of how many rows are there.
when I am doing javascript validation then I am not able to take the names of the radio buttons because I am giving them name like "radio+counter number"
like radio1,radio2 radio3......depend upon the row. in the same way for other column radio buttons also.
my HTML coding is like this:
foreach($MEMBER_ID as $key=>$val)
{
if($row2>0)
{
$BG_COLOR='#FFFFCC';
}
else
{
$BG_COLOR='';
}
$SHOW_MEMBER_DETAIL.="<table width='1663' border='0' cellspacing='0' cellpadding='0' class='simple_text'>
<input type='hidden' name='counter' value='$RM'>
<input type='hidden' name='member_id$RM' value='$row1->aid'>
<input type='hidden' name='event_id' value='$EVENT_ID'>
<input type='hidden' name='event_cat' value='$EVENT_CAT'>
<input type='hidden' name='event_month' value='$SELECT_MONTH'>
<tr bgcolor='#FFFFCC'>
<td width='58'>$RM</td>
<td width='424'>$MEMBER_NAME</td>
<td width='525'>
<input name='conf_attn$RM' id='conf_attn' type='radio' value='c_n_a'><strong>C&A</strong> &nb sp;
<input name='conf_attn$RM' id='conf_attn' type='radio' value='c_n_na'><strong>C&NA</strong> &nb sp;
<input name='conf_attn$RM' id='conf_attn' type='radio' value='nc_n_a'><strong>NC&A </strong>
<input name='conf_attn$RM' id='conf_attn' type='radio' value='nc_n_na'><strong>NC&NA</strong></td>
<td width='113'><div align='center'>
<input name='start$RM' id='start' type='radio' value='p'><strong>P</strong>
<input name='start$RM' id='start' type='radio' value='a'><strong>A</strong></div></td>
<td width='113'><div align='center'>
<input name='brake$RM' id='brake' type='radio' value='p'><strong>P</strong>
<input name='brake$RM' id='brake' type='radio' value='a'><strong>A</strong></div></td>
<td width='100'><div align='center'>
<input name='end$RM' id='end' type='radio' value='p'><strong>P</strong>
<input name='end$RM' id='end' type='radio' value='a'><strong>A</strong></div></td>
<td width='216'><div align='center'>
<select name='cand_behaviour$RM' id='cand_behaviour'>$CAND_BH</select></div></td>
<td width='114'><div align='center'><strong><a href='#' onclick=javascript:window.open('/forum//event_attendence_con_rem_1mem.html','','scrollbars=yes,toolbar=no,menubar=no,resizable=yes')>Re mark</a></strong></div></td>
</tr>
</table>";
$RM=$RM+1;
}
}
My JAVASCRIPT like this:
counter=document.submit_event_attandence.counter.value;
for(x=1; x<counter; x++)
{
var y=x;
alert(y);
myOption = -1;
myOption1 = -1;
myOption2 = -1;
myOption3 = -1;
for (i=submit_event_attandence.conf_attn+y.length-1;i > -1; i--)
{
if (submit_event_attandence.conf_attn+y.checked)
{
myOption1 = i;
i = -1;
}
}
for (j=submit_event_attandence.start+y.length-1; j > -1; j--)
{
if (submit_event_attandence.start+y[j].checked)
{
myOption1 = j;
j = -1;
}
}
for (k=submit_event_attandence.brake+y.length-1; k > -1; k--)
{
if (submit_event_attandence.brake+y[k].checked)
{
myOption2 = k;
k = -1;
}
}
for (l=submit_event_attandence.end+y.length-1; l > -1; l--)
{
if (submit_event_attandence.end+y[l].checked)
{
myOption3 = l;
l = -1;
}
}
if (myOption == -1)
{
alert('You must select a radio button of confirm and attandend');
return false;
}
if (myOption1 == -1)
{
alert('You must select a radio button of Start attandence');
return false;
}
if (myOption2 == -1)
{
alert('You must select a radio button of Brake attandence');
return false;
}
if (myOption3 == -1)
{
alert('You must select a radio button of End attandence');
return false;
}
|
|
|
|
|
|
|
// |