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 11 of 11
  1. #1
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post

    If complete, contract the div

    I want to have a script that does something like this:

    -----------------------------------------------------
    -----------------Step 1 -----------------------------
    -----------------------------------------------------
    please do blah blah blah, php is now checking for
    blah blah blah.

    -----------------------------------------------------
    -----------------Step 2 -----------------------------
    -----------------------------------------------------

    -----------------------------------------------------
    -----------------Step 3 -----------------------------
    -----------------------------------------------------

    -----------------------------------------------------
    -----------------Step 4 -----------------------------
    -----------------------------------------------------

    If step 1 is finished, and php is happy with whatever the code is in it, then contract step 1, and show step 2. How can i do this?

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    On a basic level you can use If/Else to calculate what has been submitted and tell the form at what point it is upto.

    PHP Code:
    <?php
    session_start
    ();

    $step 1;
    $submit $_POST['Submit'];

    if(isset(
    $submit)){

        if(
    $submit == 'step1'){
            if(empty(
    $_POST['name'])){
                
    $err "Please fill in your name";
                
    $step 1;
            }
            else{
                
    $_SESSION['name'] = $_POST['name'];
                
    $step 2;
            }
        }
        if(
    $submit == 'step2'){
            if(empty(
    $_POST['age'])){
                
    $err "Please fill in your age";
                
    $step 2;
            }
            else{
                
    $_SESSION['age'] = $_POST['age'];
                
    $step 3;
            }
        }
    }

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <div>
      <h3>Step1</h3>
      <?php
      
    if($step == 1){
          if(isset(
    $err)){
            echo 
    $err;
        }
      
    ?> 
      <form id="form1" name="form1" method="post" action="">
        <label>
          Name: 
          <input type="text" name="name" />
        </label>
        <label>
        <input type="submit" name="Submit" value="step1" />
        </label>
        <br />
      </form>
      <?php
      
    }
      else{
          echo 
    "Step1 complete";
      }
      
    ?>
    </div>
    <br />
    <div>
      <h3>Step2</h3>
      <?php
      
    if($step == 2){
          if(isset(
    $err)){
            echo 
    $err;
        }
      
    ?>
      Thankyou <?=$_SESSION['name']?>. Please fill in your age.
      <form id="form2" name="form2" method="post" action="">
        <label>Age:
          <input type="text" name="age" />
        </label>
        <label>
        <input type="submit" name="Submit" value="step2" />
        </label>
      </form>
      <?php
      
    }
      else{
          if(
    $step == 3){
        echo 
    "Step2 complete";
        }
        else{
          echo 
    "Please complete Step1";
        }
      }
      
    ?>
    </div>

    <?php
    if($step == 3){
    ?>
    <br />
    <div>
      <h3>Results</h3>
      <p>
    <?php    
        
    echo 'Your name: ',
        
    $_SESSION['name'],
        
    '<br />Your age: ',
        
    $_SESSION['age'];    
    }
    ?>
        </p>
    </div>
    </body>
    </html>
    You can make it look fancier using CSS and display or visibility and contractible headers.

  • #3
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    let me rephrase my first post. Lets say i add a submit button, and it will now go through and check the open step, that should make it easier.

    Also, the script you gave me, i don't see how i could use that for my means.

  • #4
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is a simple problem. Figure out how to lay out your "steps" in HTML using CSS to control of they are open or closed, then use PHP to control which CSS class is used on each div. It isn't that hard.
    "$question = ( to() ) ? be() : ~be();"

  • #5
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    here is the example of what i want it to look like with html and css.

    http://www.lonelylizard.com/~eli/tes...l/install1.php

  • #6
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    there has got to be an easier way to do what i want then what degsy posted.

    I think Velox's would work, all though im not sure exactly what he means. Can someone post an example for me to look at?

  • #7
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    *bump*

  • #8
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    *bump*

  • #9
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Its simple. Make a mockup of the setup before hand using just HTML so you can perfect CSS styles for closed steps and open steps, then use PHP to echo out the correct class names for each div, so if it's step two it echo's out the closed CSS class for all but step two's div. Not hard.
    "$question = ( to() ) ? be() : ~be();"

  • #10
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    ok, what is the php code that i use however to control the styles used?

  • #11
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It would appear that all you need to do is echo out the correct information in the right places...
    PHP Code:
    <?php
    // Other stuff
    ?>

    <div class="titlefor">
    Step 1</div>
    <?php 
    if ($step == 1) {
         include 
    'step1.php';
    }
    ?>
    <br />

    <div class="titlefor">
    Step 2</div>
    <?php 
    if ($step == 2) {
         include 
    'step2.php';
    }
    ?>
    <br />
    "$question = ( to() ) ? be() : ~be();"


  •  

    Posting Permissions

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