我正在使用JavaScript進行表單驗證,但是當我嘗試從提交到的頁面檢索數據時,我無法獲取它。表單數據沒有通過
form.html
<body>
Hello.<br />
<form onsubmit="return validate()" action="process.php" method="POST">
Enter name: <input type="text" id="name" /><br />
Enter phone number: <input type="text" id="number" /><br />
Enter password: <input type="password" id="paswd" /><br />
Is there anything else you would like to add: <input type="text" id="anything" /><br />
<input type="submit" value="Check Form" />
</form>
</body>
process.php
<?php
echo 'Here: '.$_POST['number']
?>
不管指數我用我得到 「未定義指數:2號線」。我究竟做錯了什麼?
編輯:所以我不能使用id
屬性我需要name
?因爲所有name
的值將與相應的id
相同,是否有防止編碼冗餘?
我想張貼,當你錯過了一些代碼。 – Fluffeh 2012-07-25 23:17:25