safey Posted December 15, 2012 Share Posted December 15, 2012 (edited) I have two columns in a table , first column has a select and the second has a list of checkboxes I'm using smarty to get the number of rows of the table from php , then I use a loop in script code to generate onchange event for every select cell in the table , I'm lost with syntax ! what I want that when I change the select options the checkboxes in the second cloumn become readonly or not . depeanding on the select option which has been chosen . when I open the source of the page I find that there's no code generated in the script at all , it's like the smarty code is ignored need your help to fing the error . the script : <script type="text/javascript"> $(document).ready(function() { <%section name='i' start=0 loop=$rows_number%> $('col_order<%$smarty.section.i.index%>').change(function(){ if( $('col_order<%$smarty.section.i.index%>').val=='first') { $("col_list<%$smarty.section.i.index%>_0").attr('selected','y'); $("col_list<%$smarty.section.i.index%>_0").attr('disabled',false); $("col_list<%$smarty.section.i.index%>_1").attr('selected','y'); $("col_list<%$smarty.section.i.index%>_1").attr('disabled',false); } else if( $('col_order<%$smarty.section.i.index%>').val=='second') { $("col_list<%$smarty.section.i.index%>_0").attr('selected','n'); $("col_list<%$smarty.section.i.index%>_0").attr('disabled',true); $("col_list<%$smarty.section.i.index%>_1").attr('selected','n'); $("col_list<%$smarty.section.i.index%>_1").attr('disabled',true); } }); }); <%/section%> </script> Edited December 15, 2012 by safey Quote Link to comment https://forums.phpfreaks.com/topic/272026-smarty-code-with-select-and-change-function/ Share on other sites More sharing options...
Jessica Posted December 15, 2012 Share Posted December 15, 2012 When using js in a smarty template you often have to make liberal use of the {literal} tag. You could save a lot of effort by not looping over your elements but instead using a class. Quote Link to comment https://forums.phpfreaks.com/topic/272026-smarty-code-with-select-and-change-function/#findComment-1399524 Share on other sites More sharing options...
safey Posted December 15, 2012 Author Share Posted December 15, 2012 I'm still a beginner in Web , I've read that {literal} is used to avoid conflicting with the functions { } and smarty delimiteres and I'm already using diffirent delimiteres <% and %> Quote Link to comment https://forums.phpfreaks.com/topic/272026-smarty-code-with-select-and-change-function/#findComment-1399527 Share on other sites More sharing options...
Jessica Posted December 15, 2012 Share Posted December 15, 2012 (edited) I've never seen anything that says Smarty can use those tags. Where did you see that? If you need to enable something to use those tags maybe check on that. Edit: http://www.smarty.net/docs/en/language.escaping.tpl Did you set them in your PHP? Edited December 15, 2012 by Jessica Quote Link to comment https://forums.phpfreaks.com/topic/272026-smarty-code-with-select-and-change-function/#findComment-1399534 Share on other sites More sharing options...
safey Posted December 15, 2012 Author Share Posted December 15, 2012 $smarty = new Smarty; $smarty->left_delimiter = '<%'; $smarty->right_delimiter = '%>'; Quote Link to comment https://forums.phpfreaks.com/topic/272026-smarty-code-with-select-and-change-function/#findComment-1399565 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.