Results 1 to 5 of 5

Thread: Conditional for UL LI

  1. #1
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Conditional for UL LI

    I am trying to make a conditional to only show the Div and contents inside the div/ul if the first input "Features01" has some input. Any help is appreciated! Thank you!

    PHP Code:
    <?php if (isset($_POST['Features01'])){echo "<div><h3>Features</h3><div><ul><li>$Features01</li>";}?>
    <?php 
    if (isset($_POST['Features02'])){echo "<li>$Features02</li>";}?>
    <?php 
    if (isset($_POST['Features03'])){echo "<li>$Features03</li>";}?>
    <?php 
    if (isset($_POST['Features04'])){echo "<li>$Features04</li>";}?>
    <?php 
    if (isset($_POST['Features05'])){echo "<li>$Features05</li>";}?>
    </ul>
    </div>
    </div>

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    You mean if $Features01 is not empty then echo the other li below it? If so that's fairly easy. Just do a if() and check if the $Features01 is empty.
    PHP Code:
    <?php if (isset($_POST['Features01'])){echo "<div><h3>Features</h3><div><ul><li>$Features01</li>";}
    if(!empty(
    $Features01))
    {
     if (isset(
    $_POST['Features02'])){echo "<li>$Features02</li>";}
     if (isset(
    $_POST['Features03'])){echo "<li>$Features03</li>";}
     if (isset(
    $_POST['Features04'])){echo "<li>$Features04</li>";}
     if (isset(
    $_POST['Features05'])){echo "<li>$Features05</li>";}
    }
    ?>
    </ul>
    </div>
    </div>

  3. #3
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by fastsol1 View Post
    You mean if $Features01 is not empty then echo the other li below it? If so that's fairly easy. Just do a if() and check if the $Features01 is empty.
    PHP Code:
    <?php if (isset($_POST['Features01'])){echo "<div><h3>Features</h3><div><ul><li>$Features01</li>";}
    if(!empty(
    $Features01))
    {
     if (isset(
    $_POST['Features02'])){echo "<li>$Features02</li>";}
     if (isset(
    $_POST['Features03'])){echo "<li>$Features03</li>";}
     if (isset(
    $_POST['Features04'])){echo "<li>$Features04</li>";}
     if (isset(
    $_POST['Features05'])){echo "<li>$Features05</li>";}
    }
    ?>
    </ul>
    </div>
    </div>
    Thank you! The only thing is, I need it to only show feature01 too if there is input. So if there is nothing in feature01 then the whole div and ul li should not be displayed

    Thanks again im trying to figure it out

  4. #4
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    After further testing I see how this is working. I need it to only show features that have input entered. If there is nothing in 2-5 it still shows features01. Also if I have input in any of the 2-5 fields it shows all of them, just blank..

  5. #5
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Here is the page that has the inputs if it would help you

    http://lcdforvideo.com/josh/lcd4video.html

    Thanks!

Bookmarks

Posting Permissions

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