Query on Reactivation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • refugeedeveloper@yahoo.co.in

    Query on Reactivation

    I have a short query if anyone can help me with it I will be gratefull.

    I have a php form, and have put the php code within the form itself. On
    activation the form calls itself:

    <form action="Thisfor mitself.php">

    </form>

    Problem is when I do this all the selections(eg list selections) the
    user has made are reset to null, and the form has no way of knowing
    what the user chose prior to pressing the submit button.

    If anyone can help with this I will be gratefull.

    thank you.

  • tim

    #2
    Re: Query on Reactivation


    refugeedevelope r@yahoo.co.in wrote:[color=blue]
    > I have a short query if anyone can help me with it I will be gratefull.
    >
    > I have a php form, and have put the php code within the form itself. On
    > activation the form calls itself:
    >
    > <form action="Thisfor mitself.php">
    >
    > </form>
    >
    > Problem is when I do this all the selections(eg list selections) the
    > user has made are reset to null, and the form has no way of knowing
    > what the user chose prior to pressing the submit button.
    >
    > If anyone can help with this I will be gratefull.
    >
    > thank you.[/color]

    Please post some php code from Thisformitself. php to help someone help
    you

    Tim

    Comment

    • Gordon Burditt

      #3
      Re: Query on Reactivation

      >I have a short query if anyone can help me with it I will be gratefull.[color=blue]
      >
      >I have a php form, and have put the php code within the form itself. On
      >activation the form calls itself:
      >
      ><form action="Thisfor mitself.php">
      >
      ></form>
      >
      >Problem is when I do this all the selections(eg list selections) the
      >user has made are reset to null, and the form has no way of knowing
      >what the user chose prior to pressing the submit button.[/color]

      This is the way it is supposed to work. Page hits are independent
      of each other.

      If you want the information to carry over, the PHP page generating
      the HTML needs to carry it over (e.g. take values from $_POST[] and
      insert VALUE="..." in input HTML input elements, put SELECTED in
      the appropriate location in list selections, etc.)

      Gordon L. Burditt

      Comment

      • zorro

        #4
        Re: Query on Reactivation

        this will handle select lists

        <?

        $myOptions=arra y();
        $myOptions['color1']='blue';
        $myOptions['color2']='red';

        ?>

        <select name="optList">
        <option value="">Pick one</option>
        <? displayOptionLi st($myOptions," optList"); ?>
        </select>

        <?

        function displayOptionLi st($options,$in putName){

        if($_POST)
        {
        foreach($option s as $key=>$value)
        {
        if($_POST["$inputName "]==$key)
        { echo "<option value=\"$key\" selected>$value </option>";
        }
        else
        { echo "<option value=\"$key\"> $value</option>";
        }
        }
        }
        else
        {
        foreach($option s as $key=>$value)
        { echo "<option value=\"$key\"> $value</option>";
        }
        }
        }

        ?>

        Comment

        Working...