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

javascript

P: n/a
Can someone please help me with an issue I have with Firefox that generates
in the console below when running the code below.Strange thing is that IE
runs it no problem. I don't think it's an async error though as I have seen
some posts.
Martin
Error: fValue has no properties

//---------Qty ASP Checking start
var WkKM = 1;
var WkUnits = "";
var unitslen;
var WkValue = 0;
if ( (Units != "") && (ASP != "" ) ) {
unitslen = Units.length;
TempKM = Units.substr(unitslen-1,1).toUpperCase();
if ( (TempKM== "K" || TempKM == "M") ) {
if (TempKM == "K") {
WkKM = 1000;
}
else if (TempKM == "M") {
WkKM = 1000000;
}
Units = Units.substr(0,unitslen-1);
}

WkUnits = Units* WkKM;

if ( (WkUnits == "") || (IsNumeric(ASP) == false) )
WkValue = 0;
else
WkValue = WkUnits*ASP;
}
if (WkValue <5000)
errmsg = errmsg + "There is a $5000 minimum value for each registration.
\n";
else {
//---------------Insert Value
var fValue=document.getElementById("Value");
fValue.value=WkValue;
} //---------Qty ASP Checking start
var WkKM = 1;
var WkUnits = "";
var unitslen;
var WkValue = 0;
if ( (Units != "") && (ASP != "" ) ) {
unitslen = Units.length;
TempKM = Units.substr(unitslen-1,1).toUpperCase();
if ( (TempKM== "K" || TempKM == "M") ) {
if (TempKM == "K") {
WkKM = 1000;
}
else if (TempKM == "M") {
WkKM = 1000000;
}
Units = Units.substr(0,unitslen-1);
}

WkUnits = Units* WkKM;

if ( (WkUnits == "") || (IsNumeric(ASP) == false) )
WkValue = 0;
else
WkValue = WkUnits*ASP;
}
if (WkValue <5000)
errmsg = errmsg + "There is a $5000 minimum value for each registration.
\n";
else {
//---------------Insert Value
var fValue=document.getElementById("Value");
fValue.value=WkValue;
}

Dec 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
martin said the following on 12/12/2005 5:14 AM:
Can someone please help me with an issue I have with Firefox that generates
in the console below when running the code below.Strange thing is that IE
runs it no problem. I don't think it's an async error though as I have seen
some posts.
Martin
Error: fValue has no properties


Without seeing the HTML, first guess is that you have a form field named
"Value" and that the following line:

var fValue=document.getElementById("Value");

In IE, it will incorrectly pick it up by name. Mozilla is not so
forgiving. If it is a form element, then use the forms collection:

var fValue= document.forms['formName'].elements['Value']

Not sure I would name a form field Value though. Too easy to confuse it
with the .value property of form fields.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 12 '05 #2

P: n/a
martin wrote:
Can someone please help me with an issue I have with Firefox that generates
in the console below when running the code below.Strange thing is that IE
runs it no problem. I don't think it's an async error though as I have seen
some posts.
Martin
Error: fValue has no properties

That may be because of the issue Randy has identified, the other (which
you refer to as an 'async error') is that you are running the function
before fValue exists - either the function is run before the document
has finished loading or before some other script that creates fValue has
done its job.

//---------Qty ASP Checking start
var WkKM = 1;
var WkUnits = "";
var unitslen;
var WkValue = 0;
if ( (Units != "") && (ASP != "" ) ) {
unitslen = Units.length;
TempKM = Units.substr(unitslen-1,1).toUpperCase();
The substr() method exists only for backward compatibility with some
older implementations of ECMAScript, it has been removed from the
normative part of Ed 3 (see Appendix B part 2). It may be a good idea
to use the substring method instead, its behaviour is slightly different:

substr(start, length) versus substring(start, end)
If end is lower than start, end & start will be swapped. substring
returns all characters from start up to but not including end. If no
end is specified, then all characters from start to the end of the
string are returned. If no start is specified, zero is used.

You can get rid of the unitslen variable too (I think you are just
trying to strip the last character from Units):

TempKM = Units.substring(Units.length-1).toUpperCase();
if ( (TempKM== "K" || TempKM == "M") ) {
if (TempKM == "K") {
WkKM = 1000;
}
else if (TempKM == "M") {
WkKM = 1000000;
}
Units = Units.substr(0,unitslen-1);


Here you would use:

Units = Units.substring(0,Units.length-1);
Though now the 'Units' variable is actually a number. I think maybe you
should evaluate the names you are giving variables, it isn't good to
mask the true nature of a variable, it can make debugging and
maintenance a pain.
[...]
--
Rob
Dec 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.