469,289 Members | 2,330 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

Need a little help.

Maybe someone can tell me why I am getting this error.

zip code form test
http://localhost/zip_code_auto_update.asp
Event thread: keyup
Error:
name: ReferenceError
message: Statement on line 5: Reference to undefined variable: If
Backtrace:
Line 5 of inline#2 script in
http://localhost/zip_code_auto_update.asp
If(zip.length > 4);
Line 1 of script
zipLook(this.value);
At unknown location
[statement source code not available]

<html>
<head>
<title>zip code form test</title>
<SCRIPT LANGUAGE="JavaScript" src="../_ScriptLibrary/RS.HTM"></script>
<SCRIPT LANGUAGE="JavaScript">
RSEnableRemoteScripting("../_ScriptLibrary")
</SCRIPT>
<SCRIPT TYPE="text/javascript">
function zipLook(zip)
{
If(zip.length>4)
{
var objRS = RSGetASPObject("zip_code.asp");
var objResult = objRS.lookZip(zip);

var strCityState = objResult.return_value;

var strLength = strCityState.Length;
var strEx = strCityState.indexOf('!');
var strCity = strCityState.substring(0,strEx-1);
var strST = strCityState.substring(strLength-2);

document.form1.city.value = strCity;
document.form1.state.value = strST;
document.write(strCity);
document.write(strST);
}
}
</SCRIPT>
</head>
<body>
<form name="form1" method="post">City: <input type="text" name="city"
size="30"><br />
State: <input type="text" name="state" size="4"><br />
Zip Code: <input type="text" name="zip" onKeyUp="zipLook(this.value)"
size="10"><br />
Phone: <input type="text" name="phone" size="13"><br />
</form>
</body>
</html>

Dec 9 '05 #1
1 1115

Jon Turlington wrote:
message: Statement on line 5: Reference to undefined variable: If This message gave you a hint.
<SCRIPT LANGUAGE="JavaScript" src="../_ScriptLibrary/RS.HTM"></script>
<SCRIPT LANGUAGE="JavaScript"></SCRIPT>
The language attribute is deprecated, use the type attribute instead:

<script type="text/javascript">
<SCRIPT TYPE="text/javascript">
function zipLook(zip)
{
If(zip.length>4)


Your problem lies here, as the hint given to you by the browser. In
javascript, things are case sensitive. It should be a lowercase I, your
'If' should be an 'if' instead.

Dec 9 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Marc | last post: by
7 posts views Thread by Keyed4U | last post: by
17 posts views Thread by EkteGjetost | last post: by
5 posts views Thread by Jintty | last post: by
7 posts views Thread by Galen Somerville | last post: by
12 posts views Thread by nephish | last post: by
reply views Thread by U S Contractors Offering Service A Non-profit | last post: by
5 posts views Thread by bean330 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.