Pop-up menu

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

Pop-up menu

Stephen Thirlwell
Hi

We have the following code which reads a directory list and presents it in a
pop-up menu.

[var: 'Image_list' = (File_ListDirectory: 'trip_images/')]
<select name="image_1" size="1">
<option>Please select image [Loop: ($image_list->Size)]</option>
<option>[$image_list->(Get: (Loop_Count))][/Loop]</option>
</select>

I now need to be able to show what ever filename that is stored in the
database field to be automatically selected in this list if it still exists
in the directory.

Any pointers?


Regards

Stephen



--
------------------------------
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: Pop-up menu

Karim Dahdah
Stephen,

You can do it this way with a listbox:

<select name="image_1" size="10" multiple="multiple">
<option value="file1.gif" selected="selected">file1.gif</option>
<option value="file2.gif">file2.gif</option>
<option value="file3.gif" selected="selected">file3.gif</option>
</select>

In the case above the listbox will be 10 items height (size="10") and
the files "file1.gif" and "file3.gif" are selected.

Greetz,

Karim Dahdah
-------------------------
-ASP- and Lasso Developer
www.doran.be





Stephen Thirlwell wrote:

> Hi
>
> We have the following code which reads a directory list and presents it in a
> pop-up menu.
>
> [var: 'Image_list' = (File_ListDirectory: 'trip_images/')]
> <select name="image_1" size="1">
> <option>Please select image [Loop: ($image_list->Size)]</option>
> <option>[$image_list->(Get: (Loop_Count))][/Loop]</option>
> </select>
>
> I now need to be able to show what ever filename that is stored in the
> database field to be automatically selected in this list if it still exists
> in the directory.
>
> Any pointers?
>
>
> Regards
>
> Stephen
>
>
>


--
------------------------------
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: Pop-up menu

Alan Linnenbank
In reply to this post by Stephen Thirlwell
I believe the code should read but I haven't tried it:


[var: 'Image_list' = (File_ListDirectory: 'trip_images/')]
<select name="image_1" size="1">
<option>Please select image</option>
[Loop: ($image_list->Size)]
<option [if: ($image_list->(Get: (Loop_Count))) == (field: 'yourefield')]selected[/if] value="value that needs to passed">[$image_list->(Get: (Loop_Count))]
</option>
[/Loop]

</select>


Alan



On donderdag, 16 juni 2005 12:07, Stephen Thirlwell <[hidden email]> wrote:
Hi

We have the following code which reads a directory list and presents it in a
pop-up menu.

[var: 'Image_list' = (File_ListDirectory: 'trip_images/')]
<select name="image_1" size="1">
<option>Please select image [Loop: ($image_list->Size)]</option>
<option>[$image_list->(Get: (Loop_Count))][/Loop]</option>
</select>

I now need to be able to show what ever filename that is stored in the
database field to be automatically selected in this list if it still exists
in the directory.

Any pointers?


Regards

Stephen



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



--
------------------------------
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: Pop-up menu

Stephen Thirlwell
In reply to this post by Stephen Thirlwell
On 16/6/05 11:16, "Alan Linnenbank" <[hidden email]> wrote:

> [var: 'Image_list' = (File_ListDirectory: 'trip_images/')]
> <select name="image_1" size="1">
> <option>Please select image</option>
> [Loop: ($image_list->Size)]
> <option [if: ($image_list->(Get: (Loop_Count))) == (field:
> 'yourefield')]selected[/if] value="value that needs to
> passed">[$image_list->(Get: (Loop_Count))]
> </option>
> [/Loop]
>
> </select>

Excellent - many thanks :)

Regards

Stephen




--
------------------------------
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: Pop-up menu

Wade Maxfield
In reply to this post by Stephen Thirlwell
>Hi
>
>We have the following code which reads a directory list and presents it in a
>pop-up menu.
>
>[var: 'Image_list' = (File_ListDirectory: 'trip_images/')]
><select name="image_1" size="1">
><option>Please select image [Loop: ($image_list->Size)]</option>
><option>[$image_list->(Get: (Loop_Count))][/Loop]</option>
></select>
>
>I now need to be able to show what ever filename that is stored in the
>database field to be automatically selected in this list if it still exists
>in the directory.
>
>Any pointers?
>
>
>Regards
>
>Stephen
>


This is how I've done the same thing. There may be better/more
optimised ways of doing it.


<?Lassoscript
Variable: 'imageList'=(File_ListDirectory: ($imageDirectory));
$imageList->(RemoveAll: '.DS_Store');
if: (field: 'chosenImage')=='';
   Variable: 'itemNumber'=1;
   // no image was set in database, so auto select first item in list;
else;
   Variable: 'itemNumber'=$imageList->(FindIndex: (field: 'chosenImage'));
   if: (($itemNumber->Size)==0);
     Variable: 'itemNumber'=-1;
     // current item in database wasn't found in directory;
     // display name in list, but mark it so user knows;
   else;
     Variable: 'itemNumber'=$imageList->(FindIndex: (field:
'chosenImage'))->(Get:1);
     // current item in databasewas found in directory;
   /if;
/if;
?>

<select name="theImage">
[if: (Variable: 'selected')==-1]
<option value="[field: 'chosenImage']">[field: 'chosenImage'] *</option>
[/if]
[Iterate: $imageList, (Variable: 'theItem')]
   <option value="[$theItem]" [if:
(loop_count)==$itemNumber]selected=selected[/if]>[$theItem]</option>
[/Iterate]
</select>


- Wade

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