By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Count total value from scrolldown menus.

P: n/a
Hi, I've got a little problem:

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:

Scrolldownmenu 1:
- Option A (name A) --> (this has to represent te value 10 for
example)
- Option B (name B) --> (this has to represent te value 32 for
example)

Scrolldownmenu 2:
- Option A (name A) --> (this has to represent te value 15 for
example)
- Option B (name B) --> (this has to represent te value 30 for
example)

etc.. (a few other ones)

So I wanna count the values they represent to a total and put it in a
textfield. And if you select a name that i will add that value to the
total or update it (whitout refreshing the page).

And is it then also possible to give an error message if the total
value is above a specified value?

I think it is possible with javascript but I'm not that experienced.

Hopefully I explained it good enough and someone can help me.
thanks.
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Maybe you just want to use a free script that is easy to implement and
tested:

http://www.burmees.nl/menu/menus.htm

Wouter

"ZyPhiX" <mk@zyphix.com> wrote in message
news:27**************************@posting.google.c om...
: Hi, I've got a little problem:
:
: 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:
:
: Scrolldownmenu 1:
: - Option A (name A) --> (this has to represent te value 10 for
: example)
: - Option B (name B) --> (this has to represent te value 32 for
: example)
:
: Scrolldownmenu 2:
: - Option A (name A) --> (this has to represent te value 15 for
: example)
: - Option B (name B) --> (this has to represent te value 30 for
: example)
:
: etc.. (a few other ones)
:
:
:
: So I wanna count the values they represent to a total and put it in a
: textfield. And if you select a name that i will add that value to the
: total or update it (whitout refreshing the page).
:
: And is it then also possible to give an error message if the total
: value is above a specified value?
:
: I think it is possible with javascript but I'm not that experienced.
:
: Hopefully I explained it good enough and someone can help me.
:
:
: thanks.
Jul 20 '05 #2

P: n/a
That's not exactly what I'm looking for. I mean something like on this
page:

Maybe "listbox" is a better word?
www.verstappen.nl/NL/item12/2003.html
And then I want to add a value to each option. So I can make a total
sum of the selected values.

Hope it's clear now?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

P: n/a
@SM
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/
************************************************** ************
Jul 20 '05 #4

P: n/a
Oke thanks a lot. I'm going to try it.
thx.
"@SM" <st*********************@wanadoo.fr> wrote in message news:<40***************@wanadoo.fr>...

Answer

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.