Forums

Multipage it's ok! But...

pasqualedi 02 Feb, 2010
Hi Bob!
I'v create a multipage form with 2 step.
In the first step i write the Cognome (surname)Mrtins:


When i go in the 2nd step how to have in auto the previous value of Cognome(surname)?
GreyHead 03 Feb, 2010
HI pasqualedi,

You need to set the value from the $posted array
<input name='cognome2' . . . value='<?php echo $posted['cognome']; ?>' />


Bob
pasqualedi 03 Feb, 2010
Hi Bob!Thanks very much.
For the textbox type it's ok, working..
But if i've a dropdown selection?
Thi is my code for the dropdown:
<div class="form_item">
      <div class="form_element cf_dropdown">
        <select class="cf_inputbox" id="tipocontratto" size="1" title=""  name="tipocontratto">
          <option value="" selected="selected">Scegli</option>
          <option value="Determinato">Determinato</option>
          <option value="Indeterminato">Indeterminato</option>
        </select>
      </div>
      <div class="cfclear"></div>
    </div>
GreyHead 03 Feb, 2010
Hi pasqualedi,

That needs some PHP
<?php
$tipo_options = array('Determinato' => 'Determinato', 'Indeterminato' => 'Indeterminato');
$selected = "";
$options_array = array();
foreach ( $tipo_options as $k => $v ) {
  if ( $k == $posted['tipo'] ) {
    $selected = "selected='selected'";
  }
  $options_array[] = "<option value='$k' $selected >$v</option>";
}

?>
<div class="form_item">
      <div class="form_element cf_dropdown">
        <select class="cf_inputbox" id="tipocontratto" size="1" title=""  name="tipocontratto">
          <option value="">Scegli</option>
<?php
echo implode(' ', $options_array);
?>
        </select>
      </div>
      <div class="cfclear"></div>

Bob
pasqualedi 04 Feb, 2010
Hi Bob.Thanks.
I've paste your code in my 2nd step page, but not working.
Thi is my code:
<td bgcolor="#c6d7ff"><div class="form_item">
      <div class="form_element cf_dropdown">
        <select class="cf_inputbox" id="tipocontratto" size="1" title="" name="tipocontratto">
          <option value="" selected="selected">Scegli</option>
          <option value="Determinato" >Determinato</option>
          <option value="Indeterminato">Indeterminato</option>
        </select>
        <?php
$tipocontratto_options = array('Determinato' => 'Determinato', 'Indeterminato' => 'Indeterminato');
$selected = "";
$options_array = array();
foreach ( $tipocontratto_options as $k => $v ) {
if ( $k == $posted['tipocontratto'] ) {
$selected = "selected='selected'";
}
$options_array[] = "<option value='$k' $selected >$v</option>";
}

?>
      </div>
      <div class="cfclear"></div>
    </div></td>
GreyHead 04 Feb, 2010
Hi pasqualedi,

That isn't my code - it got changed somewhere. Please use all of it including the later part which actually creates the options.

Bob
pasqualedi 04 Feb, 2010
Ok Bob!
I've paste your original code, but don't working.
<?php
$tipo_options = array('Determinato' => 'Determinato', 'Indeterminato' => 'Indeterminato');
$selected = "";
$options_array = array();
foreach ( $tipo_options as $k => $v ) {
  if ( $k == $posted['tipo'] ) {
    $selected = "selected='selected'";
  }
  $options_array[] = "<option value='$k' $selected >$v</option>";
}

?>
<div class="form_item">
      <div class="form_element cf_dropdown">
        <select class="cf_inputbox" id="tipocontratto" size="1" title=""  name="tipocontratto">
          <option value="">Scegli</option>
<?php
echo implode(' ', $options_array);
?>
        </select>
      </div>
      <div class="cfclear"></div> 
pasqualedi 04 Feb, 2010
Hi Bob!With this cod working.
<option value="Determinato"<?php if($_POST['tipocontratto']=='Determinato') print 'selected="selected"'; ?> >Determinato</option>
          <option value="Indeterminato"<?php if($_POST['tipocontratto']=='Indeterminato') print 'selected="selected"'; ?>>Indeterminato</option>
GreyHead 04 Feb, 2010
Hi pasqualedi,

What doesn't work - it produces a perfectly good drop-down?????

Bob
This topic is locked and no more replies can be posted.