If-statement

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

If-statement

Fredrik Norell
Hi all..

Could someone tell me why my if-statement won´t
work when $My_var is set to ''..?
When it is set to '', Yes gets selected in the
selectmenu. Otherwise it works like it should.

<SELECT NAME="[Field: 'id']my_select">
<OPTION VALUE="No"[If: $My_var->(Find: (Field:
'id')) == 'No' || $My_var == '']SELECTED[/If]>No
<OPTION VALUE="Yes"[If: $My_var->(Find: (Field:
'id')) == 'Yes']SELECTED[/If]>Yes
</SELECT>

Best
Fredrik
--
----------------------------
Besök gärna vår sajt! http://www.totdigital.com
----------------------------
fredrik norell
t&t digital
tel: 044-20 46 90
mobil: 0708-91 91 30
fax: 044-20 46 29
mail: [hidden email]
----------------------------
Besöksadress:
Spannmålsgatan 11
Kristianstad
----------------------------
Postadress
Box 289
291 23 Kristianstad


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: If-statement

Simon Forster

On 23 May 2005, at 11:17, Fredrik Norell wrote:

> Could someone tell me why my if-statement won´t work when $My_var  
> is set to ''..?
> When it is set to '', Yes gets selected in the selectmenu.  
> Otherwise it works like it should.
>
> <SELECT NAME="[Field: 'id']my_select">
> <OPTION VALUE="No"[If: $My_var->(Find: (Field: 'id')) == 'No' ||  
> $My_var == '']SELECTED[/If]>No
> <OPTION VALUE="Yes"[If: $My_var->(Find: (Field: 'id')) == 'Yes']
> SELECTED[/If]>Yes
> </SELECT>

Dunno. But:

<OPTION VALUE="No"[If: $My_var->(Find: (Field: 'id')) != 'Yes']
SELECTED[/If]>No
<OPTION VALUE="Yes"[If: $My_var->(Find: (Field: 'id')) == 'Yes']
SELECTED[/If]>Yes

Should do as a workaround.

HTH

Simon Forster
_____________________________________________________
  LDML Ltd, 62 Pall Mall, London, SW1Y 5HZ, UK
  Tel: +44 (0)70 9230 5244   Fax: +44 (0)70 9230 5247
_____________________________________________________


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: If-statement

Olivier Miossec
In reply to this post by Fredrik Norell

Fredrik Norell ?crit:

> Hi all..
>
> Could someone tell me why my if-statement won?t
> work when $My_var is set to ''..?
> When it is set to '', Yes gets selected in the
> selectmenu. Otherwise it works like it should.
>
> <SELECT NAME="[Field: 'id']my_select">
> <OPTION VALUE="No"[If: $My_var->(Find: (Field:
> 'id')) == 'No' || $My_var == '']SELECTED[/If]>No
> <OPTION VALUE="Yes"[If: $My_var->(Find: (Field:
> 'id')) == 'Yes']SELECTED[/If]>Yes
> </SELECT>

It's seem to me that you $My_var is a map (or an array)
So if you want to test if $My_var is empty you should use
$My_var-> size == 0.





---
Olivier Miossec
AIM/ichat omiossec
--
http://www.lasso-developpeur.net
--

--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: If-statement

jasonhuck
In reply to this post by Fredrik Norell
Try outputting the conditions on their own lines to see what each one
returns in each case.

Here I would assume $My_var is a map or array of pairs, even though
->find does work on strings:

    $My_var->(find: (field: 'id')) == 'No';

But here, I would assume $My_var is a string:

    $My_var == '';

Are you sure you didn't mean to check for this?

    $My_var->(find: (field: 'id')) == '';

--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: If-statement

Fredrik Norell
In reply to this post by Fredrik Norell
Thank you all, but It still don´t work.

$My_var is set depending of the action of the form.

If it is an update the info is fetched from a field and converted into a map.
If the action is add, I just set: My_var = '';

However, I found a workaround where I don´t set a
variable if the action is add, and then use
Var_Defined to choose the right setup of options
in my selectmenu. Not that neat, but it works...

/Fredrik



>Try outputting the conditions on their own lines to see what each one
>returns in each case.
>
>Here I would assume $My_var is a map or array of pairs, even though
>->find does work on strings:
>
>     $My_var->(find: (field: 'id')) == 'No';
>
>But here, I would assume $My_var is a string:
>
>     $My_var == '';
>
>Are you sure you didn't mean to check for this?
>
>     $My_var->(find: (field: 'id')) == '';

--
----------------------------
Besök gärna vår sajt! http://www.totdigital.com
----------------------------
fredrik norell
t&t digital
tel: 044-20 46 90
mobil: 0708-91 91 30
fax: 044-20 46 29
mail: [hidden email]
----------------------------
Besöksadress:
Spannmålsgatan 11
Kristianstad
----------------------------
Postadress
Box 289
291 23 Kristianstad


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: If-statement

stevepiercy
In reply to this post by Fredrik Norell
I notice you did not include a space between the attributes NAME and SELECTED.  Check your HTML output to see whether you get something like this:


<SELECT NAME="IDmy_select">
<OPTION VALUE="No"SELECTED>No
<OPTION VALUE="Yes">Yes
</SELECT>

If so, then simply insert a space before the "S" in "SELECTED".

--steve


On Monday, May 23, 2005, [hidden email] (Fredrik Norell) pronounced:

>Hi all..
>
>Could someone tell me why my if-statement won´t
>work when $My_var is set to ''..?
>When it is set to '', Yes gets selected in the
>selectmenu. Otherwise it works like it should.
>
><SELECT NAME="[Field: 'id']my_select">
><OPTION VALUE="No"[If: $My_var->(Find: (Field:
>'id')) == 'No' || $My_var == '']SELECTED[/If]>No
><OPTION VALUE="Yes"[If: $My_var->(Find: (Field:
>'id')) == 'Yes']SELECTED[/If]>Yes
></SELECT>
>
>Best
>Fredrik
>--
>----------------------------
>Besök gärna vår sajt! http://www.totdigital.com
>----------------------------
>fredrik norell
>t&t digital
>tel: 044-20 46 90
>mobil: 0708-91 91 30
>fax: 044-20 46 29
>mail: [hidden email]
>----------------------------
>Besöksadress:
>Spannmålsgatan 11
>Kristianstad
>----------------------------
>Postadress
>Box 289
>291 23 Kristianstad
>
>
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy               Web Site Builder               Soquel, CA
<[hidden email]>                   <http://www.StevePiercy.com>

--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage