Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I get errors for Java Scripts

Status
Not open for further replies.

ashishsmith

Programmer
Jun 23, 2004
46
US
I have a Java Script in my Cold Fusion page where I am limiting 3 fields to 500 characters and Java Script is used to truncate the field. It works fine on all computers except one and in there whenever my cursor enters the field with Java script and I start typing something It gives me an error. I don't know why. I have checked the security settings of Internet Explorer and also Advanced options. But still it is not working. Does any body have suggestion on that. Did any body had the similar problem?


Ashish Smith
 
What error do you get? What browser are you using when you get that error? Can you provide a link so someone can take a look?

[sub]
____________________________________
Just Imagine.
[sub]
 
Well, I can't send you the link because it is an internal page, I mean it is on intranet and not on internet. Sorry for that.

But I can explain you the error

Error : 'undefined' is null or not an object



This is the error I get when I press a key in the field where Java Script checks if the characters in the field have gone over 500 characters or not.

I hope this gives you a clear idea what is going on.

It happens when a key is pressed in the field, that means when Java Script starts.

Thank you for your reply

Amar Shah
 
You would be best to at least post some of the java so some one can help you. Javascript errors are incomplete and tell you little of what is really going on.

Best of luck
 
Ok here is my code to limit text area to its maximum limit if the user goes beyond the max limit

Ashish Smith




<!--- START: JAVASCRIPT: Limit TextArea --->
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}
// End -->
</script>
<!--- END: JAVASCRIPT: Limit TextArea --->
 
Are they all the same browser? Same version?

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Yep Every browsers are same and they are same version because they are supported by the company.

Ashish Smith
 
Code:
<SCRIPT LANGUAGE="JavaScript">
<!--
  function textCounter(tfield,cntfield,maxlimit) {
    if (tfield.value.length > maxlimit) {
      tfield.value = tfield.value.substring(0, maxlimit);
    } else {
      cntfield.value = maxlimit - tfield.value.length;
    }
  }
-->
</script>

Try this.. Its a slightly modified cleaned up version of your code... The primary thing I did was { bracketed } your if statement and got rid of some of the comments.

For the heck of, I also changed the name of the parameter from field to tfield. Its habit, I try not to use real words as variable names. That makes dodging reserved words easier.

Obviously its a parsing problem the with computer if everything is is alright. So cleaning out all the excess may help.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
This doesn't work, my friend.

Thank you atleast for trying to help me.

Oh one more thing if you can help me in this.

I have a print icon, which prints the records. I want to print them back to back. Is there an option where i can straight away load that option as checked through java script.

Thank you,

Ashish Smith
 
Yes JS is enables on that machine and everything JVE is also running.

I don't know still there is a problem.


Ashish Smith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top