- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Call corresponding pictures
Hi all, This might be trivial but I could't find anything on the index.
I created a drop down list of length of product of 100, 200, 300 .....
For each length, I want to display a corresponding picture of the product. I have put all pictures in a folder and name them.
Is there any function in jsl that enables this?
Thank you!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Call corresponding pictures
// there are a lot of pics here, pick 6 for the list
files = Files In Directory( "f:/pics" )[10 :: 15];
New Window( "Example",
H List Box(
cb = Combo Box(
files,
selection = cb << GetSelected();
img = New Image( "f:/pics/" || selection );
(bb << child) << delete;// clear the old one
bb << append( img ); // add the new one
),
bb = Border Box( Text Box() ) // start with a dummy old one
)
);
Remove the [10::15] to get all of the images. You may want to use FilterEach(...) to keep only the .JPG or .PNG files. This example assumes the image name is appropriate for the combo box display. If you need a different word, you could use the <<get method to get the index of the selected item and then use that to index the file name list.
The picture changes with each combo box selection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Call corresponding pictures
// there are a lot of pics here, pick 6 for the list
files = Files In Directory( "f:/pics" )[10 :: 15];
New Window( "Example",
H List Box(
cb = Combo Box(
files,
selection = cb << GetSelected();
img = New Image( "f:/pics/" || selection );
(bb << child) << delete;// clear the old one
bb << append( img ); // add the new one
),
bb = Border Box( Text Box() ) // start with a dummy old one
)
);
Remove the [10::15] to get all of the images. You may want to use FilterEach(...) to keep only the .JPG or .PNG files. This example assumes the image name is appropriate for the combo box display. If you need a different word, you could use the <<get method to get the index of the selected item and then use that to index the file name list.
The picture changes with each combo box selection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Call corresponding pictures
HI Craige, Thank you for you reply! it is exactly what I need. But I encountered a error when applying the code. I put my images in a folder, got the directory and replaced "f:/pics/". The drop down box was generated and is displayed, but no picture was shown. When I chose a picture in the drop down box, an erorr poped up and said "
file not found in access or evaluation of 'New Image' " Do you know what's the problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Call corresponding pictures
missing / when the path and filename are joined.