
November 22nd, 2004, 09:58 AM
|
|
Contributing User
|
|
Join Date: Jul 2004
Location: ASP Free Forums
Posts: 372
Time spent in forums: 21 h 35 m 13 sec
Reputation Power: 5
|
|
|
math function based on drop down list selection
I have about 19 drop down menus in a form. I need to add them up according to the user selection and then divide it by the total of available drop down menus. Each drop down menu selected should add 1 to my total. But the total of drop down menus will not be 19 as some of them may have not been selected by the user yet or the selection determine that it should not be used.
The formula I'm trying to get is:
Total # of ddl's where selection is "Task Completed"/(19 - # of ddl's where selection is "task deleted" or " " )
All ddl's are as follows:
Code:
<select name="Sponsor_#"> (# = 1 to 19)
<option value=""></option>
<option value="1">1</option>
<option value="3">3</option>
<option value="9">9</option>
<option value="Task Deleted">Task Deleted</option>
<option value="Task Completed">Task Completed</option>
I have the following code that doesn't work:
Code:
function mathSponsor()
{
for (var j=1; j<20; j++)
{
var strddl = "ddlSponsor_"+j;
if (document.SponsorForm.+strddl+.value <> "" || document. SponsorForm.+strddl+.value <> "Task Deleted")
{
counter = counter + 1;
document.write(counter);
}
}
}
I know I'm going to need a for loop and an if statement within it (I think) but I have no idea on how to start this. I also need to display the total as a percentage, how do I do that? Any reference that will get me started is appreciated.
Thanks!
Last edited by maxtrixx : November 22nd, 2004 at 10:58 AM.
|