ZyPhiX a ecrit :
I'm trying to make a webpage with a few scrolldown menu's and I want
to count the values of them. In the scrolldown menu's are no numeric
values but the have to represent one. I hope I can explain it a little
bit better:
to add the value of row (1st row, 2nd, 3rd etc) in field "MyTotal"
and
to add the values of options in field "BigTotal"
<html>
<script type="text/javascript"><!--
function getRowNumber(MyMenu,Field1,Field2) {
if(document.all) {
r = document.Field1;
c = document.Field2;
t = document.all['MyTotal'];
tt = document.all['BigTotal'];
}
else
if(document.getElementsByName) {
r = document.getElementsByName(Field1)[0];
c = document.getElementsByName(Field2)[0];
t = document.getElementsByName('MyTotal')[0];
tt = document.getElementsByName('BigTotal')[0];
}
else {
r = document.forms['MyForm'].elements[Field1];
c = document.forms['MyForm'].elements[Field2];
t = document.forms['MyForm'].elements['MyTotal'];
tt = document.forms['MyForm'].elements['BigTotal'];
}
r.value = MyMenu.options.selectedIndex+1*1;
t.value = t.value*1+r.value*1;
c.value = MyMenu.options[MyMenu.options.selectedIndex].value;
tt.value = tt.value*1+c.value*1;
if(tt.value>150) alert('That\'s too much !');
}
// --></script>
<form name="MyForm">
<p><select name="Scrolldownmenu_1"
onchange="if(this.options.selectedIndex>0)
getRowNumber(this,'showR_1','showV_1');">
<option>Choice 1
<option value="5">A
<option value="3">B
</select>
<br>choosen Row 1 :<input type=text name="showR_1">
<br>choosen Value 1 :<input type=text name="showV_1">
<p><select name="Scrolldownmenu_2"
onchange="if(this.options.selectedIndex>0)
getRowNumber(this,'showR_2','showV_2');">
<option>Choice 2
<option value="15">A
<option value="31">B
</select>
<br>choosen Row 2 :<input type=text name="showR_2">
<br>choosen Value 2 :<input type=text name="showV_2">
<p>Total rows : <input type=text name="MyTotal">
Total values : <input type=text name="BigTotal">
</form>
</html>
--
******** (enlever/remove [OTER_MOI] du/from reply url) *******
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
************************************************** ************