Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

set month and year as selected while submitting the form?

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
jerrystar
Smarty n00b


Joined: 16 May 2009
Posts: 3

PostPosted: Tue May 26, 2009 4:40 am    Post subject: set month and year as selected while submitting the form? Reply with quote

{html_select_date prefix='StartDate' time=$time start_year='-5' end_year='+1' display_days=false}


while i am submitting the form
i need to set month and year as selected .How to do this?
Back to top
View user's profile Send private message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Tue May 26, 2009 3:07 pm    Post subject: I prefer a trick Reply with quote

I prefer a trick of using minmal amount of javascripts - when something is not immediately good enough:

a. You can not use 'selected' parameter.
b. Even if you use it, every loop for <optipn>..</option> needs to be compared - dropping a very little performance.
c. Minimal javascript does not harm.

Do something tricky here, just before </body> in your page:
Code:
<script language='javascript'>
document.forms['formname'].elements['date_year'] = '{$smarty.post.date_year}';
</script>


First, note down, the name of the year/month/day fields in the form generated by Smarty. Next, add the above javascript with proper name replacement.

Less burden for getting your output, isn't it?
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General 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