I don't know JavaScript, so I just hack at existing things and use this elsewhere on my site. I want to know if it is possible to modify the following code to handle multiple id's.
so this line
I want to actually check selFreight1 thru selFreight8.
It seems you can't use a wildcard i.e.selFreight* and my efforts with switch and else if got mired in muck. (I tried getElementByName but that went no where and getElementByClass does not seem to be universally supported).
Just a simple bit to check the Shipping Methods and see if it is one of the 4 freight methods. By way of explanation I couldn't set ID's from the 3rd party shipping solution so I use
to insert a unique ID in the options based on it containing the word 'Common' (for Common Carrier which is part of the method name) and the javascript allows me to show/hide a div when they select one of these methods. Works perfect with one.
The most methods returned would be 8.
Thanks for any help. A complex solution will make my head explode so your patience appreciated.
Code:
function selFreightCheck(nameSelect) { console.log(nameSelect); if(nameSelect){ selOptionValue = document.getElementById("selFreight1").value; if(selOptionValue == nameSelect.value){ document.getElementById("isfreight").style.display = "block"; } else{ document.getElementById("isfreight").style.display = "none"; } } else{ document.getElementById("isfreight").style.display = "none"; } }
Code:
selOptionValue = document.getElementById("selFreight").value;
I want to actually check selFreight1 thru selFreight8.
It seems you can't use a wildcard i.e.selFreight* and my efforts with switch and else if got mired in muck. (I tried getElementByName but that went no where and getElementByClass does not seem to be universally supported).
Just a simple bit to check the Shipping Methods and see if it is one of the 4 freight methods. By way of explanation I couldn't set ID's from the 3rd party shipping solution so I use
Code:
<mvt:if expr="'Common' CIN l.settings:method:name">id="selFreight&mvte:method:code;"</mvt:if>
The most methods returned would be 8.
Thanks for any help. A complex solution will make my head explode so your patience appreciated.
Comment