写的一个表单提交的代码
<html>
<body>
<script type="text/javascript">
<!--javascript部分用dom的方式取的值-->
function doSubmit(){
if(document.getElementById("username").value==""||document.getElementById("password").value==""){
alert("username can not null");
return false;
}
return true;
}
</script>
<!--form标签的onsubmit事件里面必须要写return-->
<form action="index.php" method="post" οnsubmit="return doSubmit()">
username:<input id="username" name="username" type="text"/><br/>
password:<input id="password" name="password" type="text"/><br/>
<input type="submit" value="提交"/>
</form>
<div>
<!--php部分用$_POST["username"]格式取前端表单提交的值-->
<?php
echo "username:".$_POST["username"]."<br/>";
echo "password:".$_POST["password"]."<br/>";
?>
</div>
</body>
</html>