how to write javascript code inside php

前端 未结 4 1646
轻奢々
轻奢々 2020-11-28 08:23

i have a got a form, on clicking the submit button:

  1. I want to do some task in the same file (db task) AND
  2. I want the form data to be sent to test.php
4条回答
  •  再見小時候
    2020-11-28 08:24

    At the time the script is executed, the button does not exist because the DOM is not fully loaded. The easiest solution would be to put the script block after the form.

    Another solution would be to capture the window.onload event or use the jQuery library (overkill if you only have this one JavaScript).

提交回复
热议问题