Réf. : Re: [SMARTY] Array - get the key from the value
| From: | philippe dot morange at ca-indosuez dot com | Date: | Thu, 05 Dec 2002 15:57:40 +0000 |
| Subject: | Réf. : Re: [SMARTY] Array - get the key from the value | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-6655@lists.php.net to get a copy of this message | ||
I could do that, but I wanted to avoid assigning too many variables.
I'd like to keep my code as simple as possible, so assigning a variable for a task like this
will
quickly make me assign a lot of variables.
Thanks anyway.
If I don't find another way, I'll do like that.
Philippe.
Monte Ohrt <monte@ispi.net> le 05/12/2002 16:33:04
Pour : Philippe MORANGE/EST/DOSI/BANQUE_INDOSUEZ/FR@BANQUE INDOSUEZ
cc : smarty-general@lists.php.net (ccc : Philippe MORANGE/EST/DOSI/BANQUE_INDOSUEZ/FR)
Objet : Re: [SMARTY] Array - get the key from the value
you need to assign a variable (or array for multi select) that is used
for the selected elements.
$smarty->assign('selected',$_POST['select_me']);
<select name=select_me>
{html_options values=$MyTypes.ids output=$MyTypes.types
selected=$selected}
</select>
On Thu, 2002-12-05 at 08:54, philippe.morange@ca-indosuez.com wrote:
> Hi,
> I've searched the mailing-list archive without finding info on this.
>
> Here is my problem:
> I have an associative array that looks like this:
> $MyTypes = array( 'ids' => $ids,
> 'types' => $types );
>
> ids types
> -----------------------------
> 0 switched
> 1 terminated
>
>
> And I want to make a dropdown menu with this:
> {html_options values=$MyTypes.ids output=$MyTypes.types selected=???}
>
> The problem is that I want a certain option to be selected.
> How can I get the key from the value?
> Here, knowing "terminated", I want to get the "1"... which is the value of
> "terminated"...
>
> Thanks,
> Philippe.
--
Monte Ohrt <monte@ispi.net>
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php