Jump to content

[SOLVED] Keep selected option after failed submit


Recommended Posts

Hello,

 

I want to know how to keep selected option after submit. For example, I have the following select input:

................................................

<select name="id_supplier">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
..................................................
 
If i select option 2, for example, after submit, selected value is not kept and returns to the first option, o.
 
I try the following code but it is not working.
 

................................................

<select name="id_supplier">
<option value="0" {if isset(($id_supplier) && $id_supplier==0) selected="selected"}{/if}>0</option>
<option value="1" {if isset(($id_supplier) && $id_supplier==1) selected="selected"}{/if}>1</option>
<option value="2" {if isset(($id_supplier) && $id_supplier==2) selected="selected"}{/if}>2</option>
<option value="3" {if isset(($id_supplier) && $id_supplier==3) selected="selected"}{/if}>3</option>
</select>
..................................................

 

Can someone help me?

 

Thank you!

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...