OL Learn

Dynamic images from local drive with validation

I would like to use dynamic images from a folder (local drive) .
(eg., if “Total” amount is greater than 10,000 , I will use Morethan_10,000.jpg
if “Total” amount is less than 10,000 , I will use Lessthan_10,000.jpg )

From Source, I can choose only one image and where can i choose 2 dynamic images from folder and how can i do validation?

if I need to write javascript in here , please advice javascript as well.

Thank you in advance and looking forward reply.

Best Regards,
M

Hi MyatYeeMon,
For dynamic images it is advisable to use JavaScript and it is good to use selector instead of text as this will involved performance.

Below is the example of script that you may refer and you need to define image root directory file:///C:/image/dynamic_image/.

var field, result = “”;

field = record.fields[“Preference”];

if (field !== “”) result += “file:///C:/image/dynamic_image/”+ field+".png";

if (result !== “”) results.attr(“src”, result);

Hope this help, Thanks.

Best Regards,
Rostam Romainoor

Hi Rostam,

Thank you for your reply. I’ve already tried like your script above my question screenshot and it doesn’t work.
Let me explain my question again that I would like to use dynamic images from a folder (local drive) .
(eg., if “Total” amount is greater than 10,000 , I will use “Morethan_10,000.jpg”
if “Total” amount is less than 10,000 , I will use “Lessthan_10,000.jpg” )

Below is my java script screenshot that I tried and it doesn’t work.
Please advice me . Thank you for your time and looking forward reply.

Hi MyatYeeMon,
You may refer below as an example
var field = record.fields[“Total”];
var result ="";

if(field > 1000){
result = “the file directory”;
}

else
result="";

Thanks

Best Regards,
Rostam Romainoor

Hi Rostamro,

I 've already tried below java script as you mentioned but it doesn’t work. Please advice.

var field, result = “”;
field = record.fields[“Total”];
if (field < 10000) result = “file:///C:/PressConnect/Myat_Project/Promotion/Lessthan_10,000.JPG”;
else if (field > 10000) result = “file:///C:/PressConnect/Myat_Project/Promotion/Morethan_10,000.JPG”;
results.attr (“src,result”) ;

Thank You in advance. Looking forward to reply.
Best Regards,
M

Hi MyatYeeMon,
Based on the script you have tried, the reason it doesn’t work because there was no value return after the if condition. Below is the sample and you may try it based on your criteria.

Here is the url for tips and tutorial for javascript: https://www.pluralsight.com/

Hope this help, thanks

Best Regards,
Rostam Romainoor