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(My Menu,Field1,Fie ld2) {
if(document.all ) {
r = document.Field1 ;
c = document.Field2 ;
t = document.all['MyTotal'];
tt = document.all['BigTotal'];
}
else
if(document.get ElementsByName) {
r = document.getEle mentsByName(Fie ld1)[0];
c = document.getEle mentsByName(Fie ld2)[0];
t = document.getEle mentsByName('My Total')[0];
tt = document.getEle mentsByName('Bi gTotal')[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.val ue*1;
c.value = MyMenu.options[MyMenu.options. selectedIndex].value;
tt.value = tt.value*1+c.va lue*1;
if(tt.value>150 ) alert('That\'s too much !');
}
// --></script>
<form name="MyForm">
<p><select name="Scrolldow nmenu_1"
onchange="if(th is.options.sele ctedIndex>0)
getRowNumber(th is,'showR_1','s howV_1');">
<option>Choic e 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="Scrolldow nmenu_2"
onchange="if(th is.options.sele ctedIndex>0)
getRowNumber(th is,'showR_2','s howV_2');">
<option>Choic e 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/
*************** *************** *************** *************** **