Im trying to add selected option but it doesnt seem to work.I want to be able to add selected options and display them in a text box with id = tot. At the moment it does view the value in the text box but it does not add it just views the value of the option i have selected.
<script type="text/javascript">
function check_sm() {
var value1 = 0;
var sm1 = document.getElementById("slides");
for (var i = 0; i < sm1.length; i++) {
if (sm1[i].selected)
{ value1 = (eval(value1) + eval(sm1[i].value)); }
} document.getElementById("SCregistration").tot.value = value1;
}
</script>
<body>
<form>
Do you want a copy of the short course details?
<select id="slides" onChange="check_sm()">
<option value="50">Yes</option>
<option value="20">No</option>
</select>
</body>
</form>
eval()here for? It has no place here whatsoever.value1 += parseInt(sm1.value, 10);.getElementByIdonly returns one element, not a list of elements.var value1 = 0;supposed to bevar value1 = document.getElementById("SCregistration").tot.value?