Click to See Complete Forum and Search --> : Netscape Problem
ryknow
02-16-2004, 01:10 PM
I have some javascript code (see below) that works with IE but with Netscape it resets the values but then processes the whole page after resetting. IE doesn't process anymore of the page. Can someone help me with figuring out what to put in here to keep Netscape from processing the rest of my page after it resets? The main function is VerifyData. The other two are used by VerifyData.
Thanks,
Rick
function VerifyData(frmRank)
{
if (document.frmRank.rank1.value > document.frmRank.rank2.value)
{
alert ("The first ranking number must be less than or equal to the "
+"second ranking number - please reenter");
cursorRank()
return (false);
}
if (document.frmRank.rank1.value > 30)
{
alert ("The first ranking number must be less than or equal to 30.");
cursorRank()
return (false);
}
if (document.frmRank.rank2.value > 30)
{
alert ("The second ranking number must be less than or equal to 30.");
cursorRank()
return (false);
}
return true
}
function cursorRank()
{
CtrlUser = document.frmRank.rank1
reset();
CtrlUser.focus();
}
function reset()
{
frmRank.rank1.value = "1";
frmRank.rank2.value = "4";
}
gil davis
02-16-2004, 01:53 PM
Please post a link, or if you can't do that, the HTML for the FORM.
ryknow
02-16-2004, 03:35 PM
Gil,
Here is the link.
https://www.benchmarkinvesting.com/ZZZTest/DowSearchWithRank.asp
The second part of the link after benchmarkinvesting.com is:
/ZZZTest/DowSearchWithRank.asp
It wouldn't print right in the preview so I had to separate it into two pieces.
The problem occurs on the left side in the ranking boxes. You have to select what you are going to rank it by also or it defaults to the selection criteria in the boxes above. One other error I have noticed is that if I use a number in the first box that is double digits and higher than the number in the second box, it will only pop a message box if the number in the second box has a zero in front of it. It recognizes that 6 is higher than 4, but it doesn't think 10 is higher than 4. or 12 or 22, etc. But it does think that 30 is higher than 2. And 20 is higher than 1. So it is reading the second number as if the 4 is 40 or 3 is 30 or 2 is 20. Any ideas?
Thanks for any help,
Rick
gil davis
02-16-2004, 03:55 PM
Form values are STRINGs. When you compare strings to numbers, you seldom get the desired results. You can use parseInt(), parseFloat(), or Number() to cunvert string values to numbers. You can also multiply the form value by 1 to have javascript convert it free of charge.
if (document.frmRank.rank1.value * 1 > 30)
ryknow
02-16-2004, 04:16 PM
Gil,
Thanks for the help with the multiplying. Any ideas about the Netscape problem and why it continues on to read all the code on the page rather than resetting the form and waiting for the user to input new numbers and press submit again? IE resets the form and waits for the user to input further numbers and press submit again.
Thanks,
Rick
gil davis
02-16-2004, 04:28 PM
JavaScript Error:
https://www.benchmarkinvesting.com/ZZZTest/DowSearchWithRank.asp,
line 507:
syntax error.
-->
....^
Try //-->
ryknow
02-16-2004, 04:59 PM
Gil,
I don't get the error. I am using NS 7.1. so that is where I am coming from. What version are you using?
Line 507 has some ASP code so there is no javascript there.
Thanks,
Rick
gil davis
02-16-2004, 08:41 PM
You did not originally specify which version of Netscape, so I assumed it was 4.x (the hardest to code for).
You have to View|Source at the browser and count lines. ASP doesn't get to the client side, and that is where the error is.
In NS 7.1, I selected the first strategy and Ranks 1 to 10 and hit submit. The page changed and the JS console reported
Error: menu[count][0].ref has no properties ... Line: 127
However, this does not seem related to the submit problem. It is some kind of menu problem. Remember that the line number is from the client point of view.
You haven't changed the compare functions yet. Did you try my suggestion? That is probably your submit problem.
Also, this piece of code:
function reset()
{
frmRank.rank1.value = "1";
frmRank.rank2.value = "4";
}
-->
</SCRIPT>
That type of object access only works in IE. You need to qualify the object with "document.". This is also where NS 4 gave the error on line 507, the uncommented HTML comment end tag.
Also, you should not use reset() as a function name. It is a reserved word.