AshleyQuick Posted March 21, 2009 Share Posted March 21, 2009 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> <? } } ?> Link to comment https://forums.phpfreaks.com/topic/150428-help-adding-another-loop-to-existing-for-loop/ Share on other sites More sharing options...
rhodesa Posted March 21, 2009 Share Posted March 21, 2009 what is $lvNum supposed to be? 1 greater then $1? why not use: <?php for($i=2; $i<=$numberofrecipients; $i++) { $value = isset($_POST['to'][$i]) ? $_POST['to'][$i] : ''; ?> <tr> <td class="formtext3"><?php echo $i ?>.</td> <td><input id="f<?php echo $i + 1; ?>" type="text" name="to[<?php echo $i ?>]" value="<?php echo $value ?>"> <script type="text/javascript"> var f<?php echo $i + 1; ?> = new LiveValidation('f<?php echo $i + 1; ?>'); f<?php echo $i + 1; ?>.add(Validate.Email ); </script> </td> </tr> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/150428-help-adding-another-loop-to-existing-for-loop/#findComment-790097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.