Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    this.fom inside "form" tag not working?

    Hi everyone,

    I'm trying to execute a javascript function in the following manner:

    <form name="someform" action="somepage" method="post" onsubmit="return enableChk(this.form);">

    The function is:

    function enableChk(form1){
    alert(form1)
    }

    The function gets called well, but the alert gives "undefined", so I'm guessing that you can't use "this.form" inside a <form> tag. Can anyone confirm this?

    I could hardcode the form name inside the function but i want it to be re-usable, so afaik "this.form" is the only way to go. If all else fails i'll use the function on a submit button instead, which should work (in theory), but i'd like to be able to use it in the <form> tag.

    Thanks for any input! (pun intended )

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I believe you need to use "this" instead of "this.form". try that and see if it works.

  • #3
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a bunch!

    Of course! It makes sense that "this" used in the form tag would pass the form itself. Previously I was using the code on a regular link, which needed "this.form" to work properly, and it just didn't occur to me that i'd need to use only "this" when i switched to using it in the form tag.

    Thanks again!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •