Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Jan 2009
    Posts
    156
    Thanks
    47
    Thanked 0 Times in 0 Posts

    Help adding another loop to existing for loop

    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 Code:
    <?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 Code:
    <?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>
        <?
            
    }
        }
        
    ?>
    Last edited by Daniellez; 03-21-2009 at 04:19 AM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •