Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

want to retain the value in drop down list after submit

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
nilesh005600
Smarty n00b


Joined: 05 Mar 2013
Posts: 1

PostPosted: Tue Mar 05, 2013 5:05 am    Post subject: want to retain the value in drop down list after submit Reply with quote

hello all,
I have to retain the selected value in drop down list after submit. I have done it in simple PHP , but not able to convert it into smarty. Please help me to convert it to smarty.
My code is as below...

<?php
//$year = 2011;
$selectedYear = isset($_POST['year_nam']) ? $_POST['year_nam'] : $year;
?>
<select name="year_nam" id="year_nam">
<?php
for ($yr_nam = 1920; $yr_nam <= 2013; $yr_nam++)
{
$selected = ($selectedYear == $yr_nam ) ? ' selected="selected"' : "";
echo "<option value='$yr_nam' $selected>$yr_nam</option>";
}
?>
</select>
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP