Select option by clicking image
-
Hello,
How can I select an option in a dropdown box by clicking an image? Say I have three images in the form (red.png, black.png and blue.png) and a dropdown with red, black and blue selections. I want to be able to click the red image and have the red option in the dropdown selected or the client can just select the dropdown himself if they want.
I have a static php form that will do this but I need to do it in Calculated Fields Form. Here’s the code:
<p>Acrylic Color<br> <br> <img onclick="SelectADropdownItem('acrylic-dropdown','Blue')" src="../quote/swatch/blue.jpg" style= "border:none; height:44px; width:44px; cursor:pointer; margin:0 5px 0 5px;" alt="Blue Face"> <img onclick="SelectADropdownItem('acrylic-dropdown','Red')" src="../quote/swatch/red.jpg" style= "border:none; height:44px; width:44px; cursor:pointer; margin:0 5px 0 5px;" alt="Red Face"> <img onclick="SelectADropdownItem('acrylic-dropdown','Yellow')" src="../quote/swatch/yellow.jpg" style= "border:none; height:44px; width:44px; cursor:pointer; margin:0 5px 0 5px;" alt="Yellow Face"> <img onclick="SelectADropdownItem('acrylic-dropdown','Green')" src="../quote/swatch/green.jpg" style= "border:none; height:44px; width:44px; cursor:pointer; margin:0 5px 0 5px;" alt= "Green Face"><br> <img onclick="SelectADropdownItem('acrylic-dropdown','Orange')" src="../quote/swatch/orange.jpg" style= "border:none; height:44px; width:44px; cursor:pointer; margin:0 5px 0 5px;" alt="Orange Face"> <img onclick="SelectADropdownItem('acrylic-dropdown','Grey')" src="../quote/swatch/grey.jpg" style= "border:none; height:44px; width:44px; cursor:pointer; margin:0 5px 0 5px;" alt="Grey Face"> <img onclick="SelectADropdownItem('acrylic-dropdown','White')" src="../quote/swatch/white.jpg" style= "border:none; height:44px; width:44px; cursor:pointer; margin:0 5px 0 5px;" alt="white Face"> <img onclick="SelectADropdownItem('acrylic-dropdown','Black')" src="../quote/swatch/black.jpg" style= "border:none; height:44px; width:44px; cursor:pointer; margin:0 5px 0 5px;" alt="Black Face"> <img onclick="SelectADropdownItem('acrylic-dropdown','Other')" src="../quote/swatch/other.jpg" style= "border:none; height:44px; width:44px; cursor:pointer; margin:0 5px 0 5px;" alt= "Other Face"><br> <select id="acrylic-dropdown"> <option> Select here or click a color above. </option> <option value="Blue"> Blue </option> <option value="Red"> Red </option> <option value="Yellow"> Yellow </option> <option value="Green"> Green </option> <option value="Orange"> Orange </option> <option value="Grey"> Grey </option> <option value="White"> White </option> <option value="Black"> Black </option> function SelectADropdownItem(id,val) { var d = document.getElementById(id); for( var i=0; i<d.length; i++ ) { if( d[i].value == val ) { d[i].selected = true; } else { d[i].selected = false; } } }
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘Select option by clicking image’ is closed to new replies.