HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 22nd, 2004, 09:58 AM
maxtrixx maxtrixx is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: ASP Free Forums
Posts: 372 maxtrixx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #2  
Old November 22nd, 2004, 11:59 AM
maxtrixx maxtrixx is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: ASP Free Forums
Posts: 372 maxtrixx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 35 m 13 sec
Reputation Power: 5
I enhanced the code a little bit but it still won't work. I included the code to get the ddl name because I want to reuse it other ddl's. I'm calling it with the onChange attribute <select name="ddlSponsor_#" onChange="getpercent(this);">

Code:
 
<script language="javascript">
function getpercent(objDDL)
{ 
var strName=objDDL.name;
var arrTmp=strName.split("_");
var ddlType=arrTmp[0];
var totalexclude = 0;
var totalnum = 0;
var totalden = 0;
var totalprct = 0;
for (var j=1; j<20; j++)
{
var strddl = ddlType+"_"+j;
if (document.SponsorForm.+strddl+.value == "" || document.SponsorForm.+strddl+.value == "Task Deleted")
{
totalexclude = totalexclude + 1;
}
else
{
totalnum = totalnum + 1;
}
}
totalden = 19 - totalexclude;
totalprct = totalnum/totalden;
}
</script>

Last edited by maxtrixx : November 22nd, 2004 at 12:11 PM.

Reply With Quote
  #3  
Old November 22nd, 2004, 03:50 PM
maxtrixx maxtrixx is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: ASP Free Forums
Posts: 372 maxtrixx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 35 m 13 sec
Reputation Power: 5
I got this to work, if any one wants to see how see this post

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > math function based on drop down list selection


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway