User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,366 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,458 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

Processing Checkbox Information From A Form

Join Date: Jun 2006
Posts: 2
Reputation: neophyteprogram is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
neophyteprogram neophyteprogram is offline Offline
Newbie Poster

Re: Processing Checkbox Information From A Form

  #3  
Jun 9th, 2006
I was able to get help from a coworkers son on how to get my code to work (there's no way I would have ever figured it out myself!)...

Here it is...

[HTML]
<SCRIPT LANGUAGE="JavaScript">
function calculate()
{
var g = 0;
var f = 0;
var c = 0;
if (document.getElementById("g").checked) { g = 1 };
if (document.getElementById("f").checked) { f = 3 };
if (document.getElementById("c").checked) { c = 5 };
var s = g + f + c;
var ans = "Problem";
if ( s == 0) { ans = "Hey!, you need to select at least two categories."};
if ( s == 1) { ans = "Hey!, you need to also select either fast or cheap."};
if ( s == 3) { ans = "Hey!, you need to also select either good or cheap."};
if ( s == 4) { ans = "The work product will be good and fast, but it won't be cheap!"};
if ( s == 5) { ans = "Hey!, you need to also select either fast or good."};
if ( s == 6) { ans = "The work product will be good and cheap, but it won't be fast!"};
if ( s == 8) { ans = "The work product will be fast and cheap, but it won't be good!"};
if ( s == 9) { ans = "Come on! You can't have a work product that is all three!"};
document.getElementById("ans").value=ans;
}
</SCRIPT>
<TABLE>
<TR>
<TD><BIG><B>Check two of the three options below and then click the "Process" button.</B></BIG>
<hr no shade size="2">
</TD></TR>
<TR>
<TD align="left" valign="top">
<INPUT TYPE="checkbox" ID="g"> Good (i.e., accurate/correct/etc.)<br>
<INPUT TYPE="checkbox" ID="f"> Fast (i.e., on/ahead of schedule)<br>
<INPUT TYPE="checkbox" ID="c"> Cheap (i.e., on/under budget)</TD>
</TR>
<TR>
<TD>
&nbsp;
</TD>
</TR>
<TR>
<TD align="center" valign="top">
<INPUT TYPE=button VALUE="Process" onClick="calculate()">
</TD>
</TR>
<TR>
<TD align="center">
<INPUT TYPE="text" ID="ans" SIZE="75"><br>
</TD>
</TR>
</TABLE>[/HTML]
Last edited by tgreer : Jun 9th, 2006 at 2:18 pm. Reason: user ignored code tags AGAIN!!
Reply With Quote  
All times are GMT -4. The time now is 12:19 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC