...

View Full Version : Resolved Help adding another loop to existing for loop



Daniellez
03-21-2009, 01:45 AM
The $lvNum variable works for the first table row but continues to display f4 in subsequent rows. I assume it's not incrementing because I'm not integrating it into the existing for loop properly (still a novice obviously :) Can someone help and maybe explain briefly how it works?


<?php
for($i=2; $i<=$numberofrecipients; $i++) {
$value = isset($_POST['to'][$i]) ? $_POST['to'][$i] : '';
$lvNum = 3;
{
?>
<tr>
<td class="formtext3"><?php echo $i ?>.</td>
<td><input id="f<?=++$lvNum?>" type="text" name="to[<?php echo $i ?>]" value="<?php echo $value ?>">
<script type="text/javascript">
var f<?=$lvNum?> = new LiveValidation('f<?=$lvNum?>');
f<?=$lvNum?>.add(Validate.Email );
</script>
</td>
</tr>
<?
}
}
?>


Disregard, this works:


<?php
for($i=2; $i<=$numberofrecipients; $i++) {
$value = isset($_POST['to'][$i]) ? $_POST['to'][$i] : '';
$lvNum = $i + 2;
{
?>
<tr>
<td class="formtext3"><?php echo $i ?>.</td>
<td><input id="f<?php echo $lvNum ?>" type="text" name="to[<?php echo $i ?>]" value="<?php echo $value ?>">
<script type="text/javascript">
var f<?php echo $lvNum ?> = new LiveValidation('f<?php echo $lvNum ?>');
f<?php echo $lvNum ?>.add(Validate.Email );
</script>
</td>
</tr>
<?
}
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum