jgshier Posted February 3, 2018 Share Posted February 3, 2018 (edited) I know you can do a foreach, but is there a for loop ? Like in php ? I need to do this in the template file for images that need to their own id. $x = 10; for ($j=1;$j<=$x;$j++) { echo "something".$j } Edited February 3, 2018 by WHMCS ChrisD Added code into code box Link to comment Share on other sites More sharing options...
jgshier Posted February 3, 2018 Author Share Posted February 3, 2018 (edited) This is what I have in a normal php file <?php $x =10; ?> <script> $(document).ready(function(){ <?php for ($j=1;$j<=$x;$j++) { echo " $('#bigimg-$j').bighover({ width: 'auto', height: '300' });"; } ?> }); </script> How do I convert that ? Edited February 3, 2018 by WHMCS ChrisD Added code into code box Link to comment Share on other sites More sharing options...
jgshier Posted February 3, 2018 Author Share Posted February 3, 2018 Think i got it to work, but is there a better way ? {literal} <script> $(document).ready(function(){ {/literal} {for $j=1 to $z} {literal}$('#bigimg-{/literal}{$j}{literal}').bighover({ width: '{/literal}{$configMouseOverZoomSizeChannels}{literal}', height: 'auto'});{/literal} {/for}{literal} }); </script> {/literal} Link to comment Share on other sites More sharing options...
Recommended Posts