0
我在我的HTML
代碼中具有以下表單。無法在更改選項後不刷新表單值
當我忘記填寫姓, 表格會告訴我一個「泡泡消息」 You have to fill in the surname
,然後我 將填補姓,按提交按鈕和值提交。
當我忘了默認選項從<select>
改變形式將顯示 我一個「泡泡消息」 You have to choose something
,那麼我會選擇另一種選擇, 按提交按鈕,但值未提交。我總是要刷新 的頁面。你知道問題出在哪裏以及如何在不刷新的情況下實現它?
<form action="add" method="post">
...
<select id="choice" name="choice"
required oninvalid="setCustomValidity('You have to choose something')"
oninput="setCustomValidity('')">
<option value="" selected="selected"></option>
<option value="first">first</option>
<option value="second">second</option>
</select>
...
<input type="text" name="surname" id="surname" value=""
required oninvalid="setCustomValidity('You have to fill in the surname')"
oninput="setCustomValidity('')">
...
</form>
在我的回答在下面的提交值沒有問題,這意味着您需要提供完整的代碼示例。 – Timmerz 2014-11-08 18:24:15
may [this](http://stackoverflow.com/questions/26658784/php-dropdown-option-selected/26659241#26659241)幫助你? – 2014-11-08 18:25:44