View previous topic :: View next topic |
Author |
Message |
spaindre Smarty Rookie
Joined: 16 Oct 2014 Posts: 7
|
Posted: Thu Apr 30, 2015 4:37 pm Post subject: 2 foreach help |
|
|
Hello all
i'm newbie in smarty so i wanna ask help in foreach
this is my problem
i have 2 foreach
Code: |
{foreach from=$show_options item=show_options key=imdb_url}
<option value="{$show_options.imdb_url}" id="{$submit_data.imdb_url}" >{$show_options.title}</option>
{/foreach}
|
and
Code: |
{foreach from=$em_languages item=em_lang key=em_key}
<option value="{$em_key}"{if $submit_data.em_language eq $em_key} selected="selected"{/if}>{$em_lang.language}</option>
{/foreach}
|
i have 2 value in $em_key A and B
so what i wanna get
when user shoose option B on submit i wanna get
value="{$show_options.imdb_url}X"
like that
Code: |
{foreach from=$show_options item=show_options key=imdb_url}
<option value="{$show_options.imdb_url}X" id="{$submit_data.imdb_url}" >{$show_options.title}</option>
{/foreach}
|
thank you |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri May 01, 2015 3:08 pm Post subject: |
|
|
May be something like this
Code: | {foreach from=$show_options item=show_options key=imdb_url}
<option value="{$show_options.imdb_url}{$submit_data.em_language}" id="{$submit_data.imdb_url}" >{$show_options.title}</option>
{/foreach} |
|
|
Back to top |
|
spaindre Smarty Rookie
Joined: 16 Oct 2014 Posts: 7
|
Posted: Mon May 04, 2015 12:00 pm Post subject: |
|
|
U.Tews wrote: | May be something like this
Code: | {foreach from=$show_options item=show_options key=imdb_url}
<option value="{$show_options.imdb_url}{$submit_data.em_language}" id="{$submit_data.imdb_url}" >{$show_options.title}</option>
{/foreach} |
|
Dont work
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon May 04, 2015 4:30 pm Post subject: |
|
|
Of course it won't work.
You're overriding foreach variable on first round.
Code: | {foreach $show_options as $option}
<option value="{$option.imdb_url}{$submit_data.em_language}" id="{$submit_data.imdb_url}" >{$option.title}</option>
{/foreach} |
Also, I'm not sure you understand, what id attribute is. |
|
Back to top |
|
spaindre Smarty Rookie
Joined: 16 Oct 2014 Posts: 7
|
Posted: Tue May 05, 2015 10:29 am Post subject: |
|
|
AnrDaemon wrote: | Of course it won't work.
You're overriding foreach variable on first round.
Code: | {foreach $show_options as $option}
<option value="{$option.imdb_url}{$submit_data.em_language}" id="{$submit_data.imdb_url}" >{$option.title}</option>
{/foreach} |
Also, I'm not sure you understand, what id attribute is. |
Hello
thank you for your reply ,
i explain what i need , in submit they are 2 option to select (show_options and $em_languages)
$em_languages have Only 2 option A and B
on submit if em_languages eq B
i wanna get in result
Code: | value="{$show_options.imdb_url}X" |
and not
Code: | value="{$show_options.imdb_url}" |
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue May 05, 2015 12:45 pm Post subject: |
|
|
Show the code. I don't understand your narrations. |
|
Back to top |
|
spaindre Smarty Rookie
Joined: 16 Oct 2014 Posts: 7
|
Posted: Wed May 06, 2015 3:02 pm Post subject: |
|
|
U.Tews wrote: | May be something like this
Code: | {foreach from=$show_options item=show_options key=imdb_url}
<option value="{$show_options.imdb_url}{$submit_data.em_language}" id="{$submit_data.imdb_url}" >{$show_options.title}</option>
{/foreach} |
|
Thank you very much its work
i have just to move </div> under the second foreach |
|
Back to top |
|
|