Problems with javascipt and form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Louloul
    New Member
    • Aug 2010
    • 7

    #1

    Problems with javascipt and form

    hello
    I have this code for the first page
    Code:
    <form name=form>
    ...
    Date of registration:
    <script name="dt">
    d=new Date();
    AffDate(d);
    </script>
    ....
    </form>
    and i have to insert the date in a table sql using another page
    Code:
    if(isset($_POST["document.form.getElemnetsByTagName('script')"]))
    
    $dt=$_POST["document.form.getElemnetsByTagName('script')"];
    
    
    include('MySQLConnection.php');
    $result=mysql_query("INSRET INTO registration (ID_etu, level_etu, class_etu, section_etu, date_reg ) 
    values('', '".$rb."', '".$C."', '".$rd1."', '".$dt."'");
    $sql=mysql_query($result. "mysql_error()");
    ?>
    It gives me error: Notice:
    Undefined variable: dt in C:\wamp\www\www \Register.php on line 27

    Could you inform me why? And what to do?

    Thanks
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you cannot use JavaScript and PHP at the same time. PHP runs at the server and JavaScript at the client. two completely separated timelines. that is, you would have to put in the form fields’ names manually.

    second, only named form fields (<input>, <select>, <textarea>) submit values, the other HTML elements don’t.

    and while I’m at it, the function is called getElementsByTa gName().
    Last edited by Dormilich; Aug 28 '10, 10:30 AM.

    Comment

    Working...