我有一个表单,我试图合并一个重置按钮。我有一个只读文本字段,我在当天拉。我的目标是合并重置以清除所有字段,但保留日期字段。我似乎无法弄清楚如何真正这样做。我目前拥有的功能将清除一切。
这是我的功能。:
function confirm_ShortageReset()
{
var datesValue = document.getElementById('dates').value;
alert(datesValue);
//return confirm("Are you sure?");
document.getElementById('shortage').reset();
document.getElementById('dates').value = datesValue;
}
我在考虑将日期值复制到另一个变量中,一旦明确生效,就可以通过调用保存日期的变量重新输入日期。这可能吗?
这也是我的形式。
<form action = "drivers.php" target = "drivers.php" method = "post" name = "shortage" id = "shortage" onsubmit = "return validateShortage()">
<table id = "main">
<tr>
<td><table id = "shortages">
<h1> Shortages </h1>
<thead>
<tr>
<th> Date </th>
<th> Driver </th>
<th> Customer# </th>
<th> Invoice# </th>
<th> Product Description </th>
<th> Size </th>
<th> Cases </th>
<th> Bottles </th>
<th> On Truck </th>
<th> CHK Itls </th>
<th> Notes </th>
</tr>
</thead>
<tr>
<td> <input type = "text" id = "dates" size = "6" name = "dates" readonly = readonly onblur = "checkDate()" > </input></td>
<td>
<select id = "drivers" name = 'drivers' >
<option value = ""> </option>
<option value = "driver1"> driver 1 </option>
</select></td>
<td> <input type = "number" min = "1" max = "99999999" id = "customernum" name = "customernum" > </input> </td>
<td> <input type = "number" min = "1" max = "99999999" id = "invoicenum" name = "invoicenum" > </input> </td>
<td> <input type = "text" id = "proddes" name = "proddes" > </input> </td>
<td> <input type = "text" id = "size" name = "size" > </input> </td>
<td> <input type = "number" min = "0" max = "999999" id = "cs" name = "cs" > </input> </td>
<td> <input type = "number" min = "0" max = "999999" id = "btls" name = "btls" > </input> </td>
<td> <select id="ontruck" name = "ontruck">
<option value = " "> </option>
<option value = "Y"> Y </option>
<option value = "N"> N </option>
</select> </td>
<td> <select id = "chkitls" name = "chkitls" >
<option value = " "> </option>
<option value = "check1"> check1 </option>
</select> </td>
<td> <input type = "text" Id = "notes" name = "notes"> </input> </td>
</tr>
</table>
<tr>
<td><input type = "submit" value = "Submit" name = "mydrivers" > </td>
<td><input type = "reset" value = "Clear All" onclick = "return confirm_ShortageReset();"> </input></td>
</tr>
<tr ><td></td><tr /><tr ><td></td><tr /><tr ><td></td><tr />
<td> <hr /> </td>
</table>
</form>
答案 0 :(得分:0)
请检查此代码
<script type="text/javascript">
function confirm_ShortageReset(){
var datesValue = document.getElementById('dates').value;
document.getElementById('shortage').reset();
document.getElementById("dates").setAttribute('value',datesValue);
}
</script>