X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   incrementing value in section loop (https://forum.x-cart.com/showthread.php?t=15117)

Gibberish 07-10-2005 09:44 PM

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}">

shan 07-11-2005 02:49 AM

something like this ?

http://smarty.php.net/manual/en/section.property.index.php

Gibberish 07-11-2005 06:27 AM

Perfect. Thanks a lot Shan.


All times are GMT -8. The time now is 11:18 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.