Jump to content

Selectbox


comodo

Recommended Posts

Hi!

 

I have questionary page where people must select some values but it doesn't remember the selected values when you go back to edit.

 

I select post-132766-0-32408300-1350378471_thumb.jpg and save but it goes back to post-132766-0-97784700-1350378541_thumb.jpg

 

I am new in PHP ,sorry :)

 

Code:

 

 

 

 

<tr>

<td width="100" align="right" class="key"><?php echo JText::_( 'Staatus' ); ?>: </label></td>

<td><select name="proforma" id="proforma">

<?php

 

$Noproforma = " ";

$proforma = " ";

?>

<option> </option>

<option <?php echo $proforma;?> value="NoProforma"><?php echo JText::_('NoProforma');?></option>

<option <?php echo $proforma;?> value="Proforma"><?php echo JText::_('Proforma');?></option>

</select></td>

</tr>

Link to comment
https://forums.phpfreaks.com/topic/269516-selectbox/
Share on other sites

That has no bearing on the problem, and not a problem at all. staatus is the label, which is showing.

 

The problem at hand is two-sided:

  1. The browser does not keep the form details in the history, so when you go back in the history it'll show the form as sent by the server.
  2. Your users have to go back in the history to edit the details, instead of you adding the user-inputted data into the form and show it anew. Alongside the error message.

Link to comment
https://forums.phpfreaks.com/topic/269516-selectbox/#findComment-1385521
Share on other sites

create a session variable for your first submission.

 

$selectedvalue = $_SESSION['selectedvalue'];

 

and in the select box you must include a selected="selected" there for the code should be like

 

<option <?php echo $selectedvalue;?> value="<?php $selectedvalue ?>" selected="selected"><?php echo $selectedvalue></option>

<option <?php echo $proforma;?> value="NoProforma"><?php echo JText::_('NoProforma');?></option>

Link to comment
https://forums.phpfreaks.com/topic/269516-selectbox/#findComment-1386064
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.