tbravo
07-21-2012, 01:48 AM
Of course I'm a newbie, but I've looked high and low and have yet to see anything similar to what I am doing.
Being a professional myself, I highly respect your time and therefore do not wish to waste it, but it is the end of my day and I still can't figure it out. I'm sure it's something simple and stupid. Please help.
I am trying to set up either a switch with one case and multiple actions or one button with multiple actions. I have no preference. Currently I'm using the one button multiple actions scenario.
I then need to display those results in an html document. It doesn't have to be pretty now. I can work on that later.
Below is the code I'm working with:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Bill Calculator</title>
</head>
<body>
<h1 style="color: red">Bill Calculator</h1>
<h3> This document should allow a ratepayer to review their old rate and see their new rate as well as the difference between the two.</h3>
<hr />
<form name="form1" action ="#">
HCF: <input type="text" name="text1" value="-" />
<br /><br />
Current Rate: <input type="text" id="currentRate" />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
function billcalculator1()
{
hcf = document.form1.text1.value;
var current = null;
switch (hcf)
{
case '1':
current = '13.22';
break;
case '2':
current = '14.52';
break;
default:
alert("Please round your usage to the nearest whole number.");
}
document.getElementById("currentRate").value;
}
//]]>
</script>
<br /><br />
Proposed Rate: <input type="text" id="proposedRate" />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
function billcalculator2()
{
hcf = document.form1.text1.value;
var proposed = null;
switch (hcf)
{
case '1':
proposed = '17.54';
break;
case '2':
proposed = '18.36';
break;
default:
alert("Please round your usage to the nearest whole number.");
}
document.getElementById("proposedRate").value;
}
//]]>
</script>
<br /><br />
Difference: <input type="text" id="theDifference" />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
function billcalculator3()
{
hcf = document.form1.text1.value;
var difference = null;
switch (hcf)
{
case '1':
difference = '+4.32';
break;
case '2':
difference = '+3.84';
break;
default:
alert("Please round your usage to the nearest whole number.");
}
document.getElementById("theDifference").value;
}
//]]>
</script>
<br /><br />
<input type="button" value="Calculate Your New Bill"
onclick="billcalculator1(); billcalculator2(); billcalculator3()" />
</form>
</body>
</html>
Once I can figure out the basics of this I can continue developing it. I don't even know where to start with what I've done wrong. I've been learning javascript slowly and painfully on my own, as needed.
No, this is not for a class. No, I'm not a student. Once again, I humbly ask for your assistance. Thank you for even reading this, I'm at my wits end.
Being a professional myself, I highly respect your time and therefore do not wish to waste it, but it is the end of my day and I still can't figure it out. I'm sure it's something simple and stupid. Please help.
I am trying to set up either a switch with one case and multiple actions or one button with multiple actions. I have no preference. Currently I'm using the one button multiple actions scenario.
I then need to display those results in an html document. It doesn't have to be pretty now. I can work on that later.
Below is the code I'm working with:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Bill Calculator</title>
</head>
<body>
<h1 style="color: red">Bill Calculator</h1>
<h3> This document should allow a ratepayer to review their old rate and see their new rate as well as the difference between the two.</h3>
<hr />
<form name="form1" action ="#">
HCF: <input type="text" name="text1" value="-" />
<br /><br />
Current Rate: <input type="text" id="currentRate" />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
function billcalculator1()
{
hcf = document.form1.text1.value;
var current = null;
switch (hcf)
{
case '1':
current = '13.22';
break;
case '2':
current = '14.52';
break;
default:
alert("Please round your usage to the nearest whole number.");
}
document.getElementById("currentRate").value;
}
//]]>
</script>
<br /><br />
Proposed Rate: <input type="text" id="proposedRate" />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
function billcalculator2()
{
hcf = document.form1.text1.value;
var proposed = null;
switch (hcf)
{
case '1':
proposed = '17.54';
break;
case '2':
proposed = '18.36';
break;
default:
alert("Please round your usage to the nearest whole number.");
}
document.getElementById("proposedRate").value;
}
//]]>
</script>
<br /><br />
Difference: <input type="text" id="theDifference" />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
function billcalculator3()
{
hcf = document.form1.text1.value;
var difference = null;
switch (hcf)
{
case '1':
difference = '+4.32';
break;
case '2':
difference = '+3.84';
break;
default:
alert("Please round your usage to the nearest whole number.");
}
document.getElementById("theDifference").value;
}
//]]>
</script>
<br /><br />
<input type="button" value="Calculate Your New Bill"
onclick="billcalculator1(); billcalculator2(); billcalculator3()" />
</form>
</body>
</html>
Once I can figure out the basics of this I can continue developing it. I don't even know where to start with what I've done wrong. I've been learning javascript slowly and painfully on my own, as needed.
No, this is not for a class. No, I'm not a student. Once again, I humbly ask for your assistance. Thank you for even reading this, I'm at my wits end.