peteyb
10-15-2007, 07:25 AM
Hi all
I use the following code to declare all the posted variables within my form to the session array:
<?php
session_start();
foreach($_POST as $key => $value)
{
$_SESSION[$key] = $value;
}
?>
Whilst this stores the data in the array I then have to use a the following code on each individual input tag to make the browser display the selected option when a user returns to the page.
<select id='value_claim3' name='value_claim3' size='1'>
<option value="0" <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '0') { ?>selected="selected"<? } ?>></option>
<option value=250 <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '250') { ?>selected="selected"<? } ?>>£0 - £500</option>
<option value=750 <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '750') { ?>selected="selected"<? } ?>>£501 - £1,000</option>
<option value=1250 <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '1250') { ?>selected="selected"<? } ?>>£1,001 - £1,500</option>
<option value=1750 <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '1750') { ?>selected="selected"<? } ?>>£1,501 - £2,000</option>
<option value=2001 <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '2001') { ?>selected="selected"<? } ?>>Over £2000</option>
</select>
Is there a short bit of code similar to the referencing method shown first whereby the browser will display the selected option?
I use the following code to declare all the posted variables within my form to the session array:
<?php
session_start();
foreach($_POST as $key => $value)
{
$_SESSION[$key] = $value;
}
?>
Whilst this stores the data in the array I then have to use a the following code on each individual input tag to make the browser display the selected option when a user returns to the page.
<select id='value_claim3' name='value_claim3' size='1'>
<option value="0" <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '0') { ?>selected="selected"<? } ?>></option>
<option value=250 <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '250') { ?>selected="selected"<? } ?>>£0 - £500</option>
<option value=750 <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '750') { ?>selected="selected"<? } ?>>£501 - £1,000</option>
<option value=1250 <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '1250') { ?>selected="selected"<? } ?>>£1,001 - £1,500</option>
<option value=1750 <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '1750') { ?>selected="selected"<? } ?>>£1,501 - £2,000</option>
<option value=2001 <?php if(isset($_SESSION['value_claim3']) && $_SESSION['value_claim3'] == '2001') { ?>selected="selected"<? } ?>>Over £2000</option>
</select>
Is there a short bit of code similar to the referencing method shown first whereby the browser will display the selected option?