View Full Version : getting values from listbox

Mar 26th, 2007, 01:29 AM
I dont have a clue about javascript i normally use php
I have a problem i cannot solve using php.

Basically i have a number of listboxes with quantitys in them and i want to get the total of the quantitys for all the listboxes on the current page and have it displayed at the top of the page.These listboxes can be changed by the user on the page and when this happens i want to check the value again.

Any help would be much appreciated

Mar 26th, 2007, 05:24 AM
var frm = document.forms[0];
var val1 = frm.select1.value;
var val2 = frm.select2.value;
var total = Number(val1) + Number(val2);

Mar 26th, 2007, 07:58 PM
Glenn why forms[0]?

Mar 26th, 2007, 09:51 PM
I don't know the form name that bunny1 uses so I just use forms[0] to refer to the first form. Of course, this can be changed to whatever the form name is.

Mar 27th, 2007, 02:11 AM
I gotcha, thanks