Source language: Translate to:

Replacing image dynamically

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

Replacing image dynamically

Postby Ronnie » Tue Jun 14, 2016 9:03 pm

Hi
How do I replace image dynamically...
Below code doesn't work when I tried to change image [imgA] to [img1] which should show "c:\temp\d1.png"


SetVar [img1] "c:\temp\d1.png"
SetVar [img2] "c:\temp\d2.png"
SetVar [img3] "c:\temp\d3.png"
SetVar [img4] "c:\temp\d4.png"
SetVar [img5] "c:\temp\d5.png"

Button script:
SetVar [imgA] [img1]

Thanks
Ronnie
 
Posts: 6
Joined: Thu May 19, 2005 4:06 pm

Re: Replacing image dynamically

Postby luishp » Wed Jun 15, 2016 2:31 am

Ronnie, for this to work you must assign [imgA] variable to Source image property on the properties panel.
On the other hand, browsers use normal slashses for URLs:

Code: Select all
SetVar [img1] "c:/temp/d1.png"
SetVar [img2] "c:/temp/d2.png"
SetVar [img3] "c:/temp/d3.png"
SetVar [img4] "c:/temp/d4.png"
SetVar [img5] "c:/temp/d5.png"

Button script:
SetVar [imgA] [img1]


Anyway, using absolute paths is not a good idea when dealing with webapps.
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 359
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: Replacing image dynamically

Postby Ronnie » Wed Jun 15, 2016 6:43 pm

Thanks.
When compiled to web, the image don't show even when I added the images via Project > Properties > Libraries/Files.
I noticed the images are stored in 'img' folder in the compiled web..

To resolve, I stored all required images to a 'img' sub folder, added to Libraries/Files, and changed the script to:

SetVar [img1] "img/d1.png"

That works.
Ronnie
 
Posts: 6
Joined: Thu May 19, 2005 4:06 pm


Return to General NeoAppBuilder Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron