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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript query

    Trying the code below to insert data into a table, the insert works properly but it gives javascript error on page. The error is 'Object doesnt this property or method'
    <?
    /*
    db connection string goes here
    */
    ?>
    <html>
    <head>
    <title> New Document </title>
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    </head>
    <body>
    <script language="JavaScript">
    <!--
    function Validate()
    {
    if (document.test.txtname.value=="")
    {
    alert("Name cannot be blank");
    event.returnValue=false;
    }

    }
    //-->
    </script>
    <form name="test" method="get" action="testSubmit.php" onSubmit= "Validate();" >
    Name: <input type="text" name="txtname" id="txtname" value="<? echo "asdsdfsdfsdf"; ?>">
    <input type="submit" name="submit" value="Submit">
    <?
    if (isset($_GET["submit"]))
    {
    /*Inserts data into a table*/
    }
    ?>
    </body>
    </html>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    function Validatef()
    {
    if (f.elements['txtname'].value=="")
    {
    alert("Name cannot be blank");
    return false;
    }
    }

    ...
    <form name="test" method="get" action="testSubmit.php" onsubmit= "return Validate(this);" >
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,963
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Quote Originally Posted by Kor
    function Validatef()
    {
    if (f.elements['txtname'].value=="")
    {
    alert("Name cannot be blank");
    return false;
    }
    }

    ...
    <form name="test" method="get" action="testSubmit.php" onsubmit= "return Validate(this);" >
    You forgot the parameter.

    Code:
    function Validatef(f)

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    yeap, sorry, but you have mistyped as well

    function Validate(f)
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,963
    Thanks
    0
    Thanked 236 Times in 233 Posts
    I just followed what you had, and I didn't notice that you just misplaced the f.


  •  

    Posting Permissions

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