By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,176 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

Table Works with IE- But Not Firefox or Netscape

P: n/a
I have a table that works fine in IE, but doesn't work in Netscape or
Firefox. It should automatically come up with numbers in some of the
fields and depending what is entered, it should calculate and come up
with a dollar amount.

If anyone out there sees what I am doing wrong- could you offer some
advice? I apologize in advance for adding the entire code- I know it
is more than most of you are willing to look at, but I just can't
figure out what part of it I messed up. Here it is:

<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<TD valign="top" align="left" width="1" bgcolor="#6633CC"></TD>
<TD valign="top" align="left">
<!-- #BeginEditable "body" -->
<TABLE width="100%" border="0" cellspacing="0" cellpadding="5"
align="center">
<TR>
<TD>
<br><br><br><br>
<HR size="1" noshade>
<FORM name="calculator">
<TABLE width="95%" border="1" cellspacing="0"
cellpadding="3" align="center" bgcolor="#6699CC">
<TR>
<TD>
<SCRIPT language="JavaScript"><!-- hide script
function currency(anynum) {
//-- Returns passed number as string in $xxx,xxx.xx format.
anynum=eval(anynum)
workNum=Math.abs((Math.round(anynum*100)/100));workStr=""+workNum
if (workStr.indexOf(".")==-1){workStr+=".00"}
dStr=workStr.substr(0,workStr.indexOf("."));dNum=d Str-0
pStr=workStr.substr(workStr.indexOf("."))
while (pStr.length<3){pStr+="0"}

//--- Adds comma in thousands place.
if (dNum>=1000) {
dLen=dStr.length
dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen)
}

//-- Adds comma in millions place.
if (dNum>=1000000) {
dLen=dStr.length
dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen)
}
retval = dStr + pStr
//-- Put numbers in parentheses if negative.
if (anynum<0) {retval="("+retval+")"}
return "$"+retval
}
//-- Do the calculation based on three passed values.
function calc() {

//--Evaluate expression and display in appropriate table cell.
exemption = 500
tax = 0.0016
rounded_num = (Math.ceil(document.calculator.value01.value/500) * 500)
// the variable number without dollars and commas.
document.calculator.value02.value = currency(rounded_num) // adding
dollars and commas.
document.calculator.value03.value = exemption
document.calculator.value04.value = currency(rounded_num - exemption)
// adding dollars and commas.
document.calculator.value05.value = tax
total = (rounded_num - exemption) * tax
document.calculator.total.value = currency(total) //adding dollars and
commas.

}

// unhide script -->
</SCRIPT>
<B><div align="center"><font size="+1">Iowa Real
Estate Transfer Tax
Calculator</font></div></font></B><NOSCRIPT>Requires
JavaScript enabled to operate.</NOSCRIPT>
<HR size="1">
<I> <div style="text-align:justify;">Type your
numeric value in the appropriate boxes, then
click anywhere outside that box or press the Tab
Key for the
total amount due.</I> <I>Do not type commas (,) or
dollar
signs ($) into number fields. Press TAB for
result</div></I>
<TABLE align="center" cellpadding="3"
cellspacing="0" width="100%">
<TR align="left" valign="middle"
bgcolor="#6699CC">
<TD align="right">$</TD>
<TD align="right">
<INPUT name="value01" size="15"
onChange="calc()" maxlength="10">
</TD>
<TD align="left" colspan="2">Total Amount
Paid</TD>
</TR>
<TR align="left" valign="middle">
<TD align="right">= $</TD>
<TD align="right">
<INPUT name="value02" size="15" value="0"
maxlength="0">
</TD>
<TD align="left" colspan="2">Rounded Up to
Nearest $500
Increment</TD>
</TR>
<TR align="left" valign="middle">
<TD align="right">- $</TD>
<TD align="right">
<INPUT name="value03" size="15" value="500"
maxlength="0">
</TD>
<TD align="left" colspan="2">Exemption</TD>
</TR>
<TR align="left" valign="middle">
<TD align="right">= $</TD>
<TD align="right">
<INPUT name="value04" size="15" maxlength="0"
value="0">
</TD>
<TD align="left" colspan="2">Taxable
Amount</TD>
</TR>
<TR align="left" valign="middle">
<TD align="right">x $</TD>
<TD align="right">
<INPUT name="value05" size="15" maxlength="0"
value=".0016">
</TD>
<TD align="left" colspan="2">Tax</TD>
</TR>
<TR align="left" valign="middle"
bgcolor="#6699CC">
<TD align="right" colspan="2"><FONT
color="#000000"><B>
Amount Due = $</B></FONT></TD>
<TD align="left">
<INPUT name="total" size="15" maxlength="0">
</TD>
<TD align="left">
<INPUT type="button" name="button"
value="Submit" onClick="calc()">
<INPUT type="reset" name="Reset"
value="Reset">
</TD>
</TR>
</TABLE>
<DIV align="center">
<HR size="1">
</DIV>
</TD>
</TR>
</TABLE>
</FORM>
<SCRIPT language="JavaScript">
<!--
//-- This little script, executed after form has been rendered,
//-- puts the cursor into the userName field so it's ready when page
opens.
// document.calculator.value01.focus()
// -->
</SCRIPT>
<HR size="1" noshade>
<P><div style="text-align:justify;">You may calculate real
estate transfer tax by entering the total
amount paid for the property. This calculation is based
on $1.60
per thousand and the first $500 is exempt.</div></P>
</TD>
</TR>
</TABLE>
<!-- #EndEditable -->
</TD>
</TR>
</TABLE>
<TABLE width="700" border="0" cellspacing="0" cellpadding="5"
align="center" bgcolor="#006600">
<TR>
<TD><FONT size="-1" color="#FFFFFF"><B></B></FONT></TD>
</TR>
</TABLE>
</BODY>

Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
This one's hard to spot and really funny. It's not a script error -
you've simply set the max length of your input fields to zero! :-D

Jul 23 '05 #2

P: n/a
Paul R-

You are a GENIUS!!! Are hugs allowed here???????? I'm not sure why IE
worked with the zero in the input fields, but now my other browsers are
working like they should.

I don't know how much longer I would have tried testing that page
before I realized what I had done wrong.

Thank you SO much for taking the time to look at the whole thing for
me!!!

Kim14

Jul 23 '05 #3

P: n/a
Kim14 wrote:
[...]
I'm not sure why IE worked with the zero in the input fields...


It depends on your definition of "worked".

IE displays your default values, but attempting to change them
results in exactly the same behaviour as Firefox - you can't
enter any text in the fields with maxlength="0".

It would appear that IE does not apply the value of the
maxlength attribute to the default value whereas Firefox does.

The HTML 4.01 spec says:

"...this attribute specifies the maximum number of characters
the user may enter."

Which I guess means that IE's approach is more compliant - it
only restricts what the user can enter and allows the value
attribute to be displayed (and submitted) regardless. Firefox
appears to remove the value completely - the value of the input
when submitted is empty.

--
Rob
Jul 23 '05 #4

P: n/a
Thanks so much to Paul & Rob for your help! I just didn't see my
error, no matter how many times I looked at it. And the explanation
was helpful just to see the differences between the browsers since I am
new to this.

I really appreciate the fact that you took the time to look at my whole
page, that is probably a big no-no to post so much information here.

Hugs to both of you!

Kim

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.