Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

incrementing value in section loop

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 07-10-2005, 09:44 PM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default incrementing value in section loop

I have the following code which loops through and creates an array of the sections. The problem with it is I am using the serviceid to define the array number. So instead of being event_services[0], event_services[1], event_services[2]. It is outputting like event_services[12], event_services[17], event_services[32].

How can I get it to output event_services[0], event_services[1], event_services[2]?

Code:
{section name=list_num loop=$services_list} <INPUT type="hidden" name="event_services[{$services_list[list_num].serviceid}][serviceid]" value="{$services_list[list_num].serviceid}"> <INPUT type="hidden" name="event_service[{$services_list[list_num].serviceid}][product]" value="{$services_list[list_num].product}"> <TR bgColor="#E1E8EE"> <TD ><INPUT type="checkbox" name="event_service[{$services_list[list_num].serviceid}][add]" value="true"></TD> <TD align="center"><INPUT type="text" name="event_service[{$services_list[list_num].serviceid}][amount]" align="right" size="2" value="{$services_list[list_num].min_amount}"></TD> <TD class="ProductSelect">{$services_list[list_num].product}</TD> <TD align="right" nowrap>${$services_list[list_num].price} (each)</TD> </TR> {/section}

If I write it like the following it seems like list_num is undefined, only ont he "name part though, the "value" part works great.
Code:
<INPUT type="hidden" name="event_services[{$list_num}][serviceid]" value="{$services_list[list_num].serviceid}">
__________________
Gibberish
[Unix] X-Cart 4.0.12
Reply With Quote
  #2  
Old 07-11-2005, 02:49 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

something like this ?

http://smarty.php.net/manual/en/section.property.index.php
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #3  
Old 07-11-2005, 06:27 AM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default

Perfect. Thanks a lot Shan.
__________________
Gibberish
[Unix] X-Cart 4.0.12
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:16 PM.

   

 
X-Cart forums © 2001-2020