Community Forums 

Main Content

Re:How to change image during choose of product from drop down menu

    Jul 11 2016 12:32:28

    #1

    Geoff

    Join date : 2008-09-18      Posts : 415

    The scripts that you have found are jquery (server-side javascript). To use these scripts you would also need to upload and reference the associated jquery libraries.

    Below is a simple client-side javascript which will do what you need

    <form>

    <select name="product[]" onChange="document.images['pic'].src='images/'+this.options[this.selectedIndex].value+'.jpg'">
    <option value="gold" selected>15ml Gold Metallic</option>
    <option value="silver">15ml Silver Metallic</option>
    <option value="copper">15ml Copper Metallic</option>
    </select>

    </form>

    <img name="pic" src="images/gold.jpg">

    (In this example, the images would be stored in a folder named "images", and the images named as the option values)