Paul said:
Correct ... but I already mentioned that I was JS illiterate.
And I said it is not really a JavaScript problem, but a programming problem.
[...]
I did manage to hack something I found out there, which is what I should
have done in the first place instead of wasting y'all's time. My humble
appologies. Just for the record, here is what I came up with.
I think you could have used your time better than this. Hints are all over
this newsgroup, especially this week. I'll be as concise as possible, if
you have any questions after you did research on existing articles, feel
free to ask.
It do give us a close figure. With direct deposit, our payment shows up on
Wednesday. We don't receive our actual pay stub until Friday. This gives
us an approximate value in the mean time to ascertain we didn't get
screwed ( management has a way of screwing up our payrolls ):
<script language="JavaScript">
<script type="text/javascript">
See
http://validator.w3.org/
Remove that nonsense.
function wage1() {
a = 113.24/17.3;
b = a*document.form1.b.value;
var a = ...;
var b = a * document.forms["form1"].elements["b"].value;
document.form1.total1.value = b
document.forms["form1"].elements["total1"].value = b
However, it can be written more efficient, see below.
Remove that line.
</script>
<form name="form1">
<form action="" name="form1">
But your form does not need a name, see below.
<table border="1" cellpadding="1" cellspacing="1">
Use CSS instead.
<tbody>
<tr>
<td colspan="3" align="center"><b><font size="4">Approx. Take Home
Pay</font></b>
Don't use the deprecated `font' element, use CSS instead. Since it is a
heading, you don't need CSS (but you can use it); use a hX element to mark
that up as a heading.
</td>
</tr><tr>
<td>Hours worked <input size="5" name="b">?</td> <td>Approx:$ <input
maxlength="10" size="5" name="total1"></td> <td><input
onclick="wage1()" value="Calculate" type="button"></td>
</tr>
<tr>
<td colspan="3" align="center"><input value="Reset" type="reset"></td>
</tr>
</tbody> </table>
</form>
You don't need a table at all with this approach, some DIVs suffice.
However, it would be better if you used a table for what it is, a
means to display tabular information.
<h1 style="text-align: center">Approx. Take Home Pay</h1>
<form action="">
<script type="text/javascript">
function wage1(o)
{
o.form.elements["total1"].value =
113.24/17.3 * o.form.elements["b"].value;
}
</script>
<table>
<tr>
<th style="text-align: left">Hours worked:</th>
<td><input name="b" size="5"></td>
</tr>
<tr>
<th style="text-align: left">Approx. ($):</th>
<td><input name="total1" maxlength="10" size="5" readonly></td>
</tr>
</table>
<div>
<script type="text/javascript">
document.write(
'<input type="button" value="Calculate" onclick="wage1(this)">');
</script>
<input type="reset" value="Reset">
</div>
</form>
Please provide proper attribution, see
http://www.jibbering.com/faq/faq_notes/clj_posts.html
HTH
PointedEars