split the source of images depending upon selection

165 Views Asked by At

What is the best way to load images from two separate sources depending upon users selection, in this case selection of dates? Is it possible to have 2 different src paths dependent on conditions? Any advice would be appreciated. Here's the relevant code:

onSelect: function(dateText, inst) {
$("#img").attr("src", "myimagesrc" + dateText + ".jpg"); 
1

There are 1 best solutions below

0
On

You don't. What you do is you parse dateText, check - in your case the year - and then set the src attribute.