javascript - 刷新时如何使用 select onchange 保留值?
问题描述
我可以切换输出值,但是当我点击刷新时,该值被重置。我需要留下的价值。
function dateFunction() {
var x = document.getElementById("ClaimContact").value;
if (x == 0){
document.getElementById("answer").value = "Yes";
}
if (x != 0){
document.getElementById("answer").value = "No";
}
}
<table width="100%" cellspacing="0" cellpadding="0" border="1" rules="rows" class="QuestionTable">
<tr>
<td #questionstyle# width="10%">Contact?</td>
<td>
<select name="ClaimContact" id="ClaimContact" onchange="dateFunction()">
<option value=""></option>
<option value="0">Y</option>
<option value="1">N</option>
</select>
</td>
<td #answerstyle# align="right">
<input type="text" id="answer" readonly style="border: none; text-align: right;">
</td>
</tr>
</table>
解决方案
您是否将值存储在任何地方?如果没有将所选值存储在本地存储中,它将起作用
推荐阅读
- go - 通过 switch 语句分配类型/创建结构
- r - (R/SHINY) - 使用 selectInput 选择要显示的(哪个)反应表
- python - 限制 PyAutoGui 的鼠标功能可以工作的区域
- ansible - 干燥的 Ansible 剧本?
- python - Pandas:添加一个 excel SUMIF 列,例如 =A1/SUMIF(B:B,B1,A:A)
- html - 在标题词之间放置图像
- android - 如何在 Android Studio 的 Platte 工具栏中更改图标颜色
- java - 使用链接打开我的 Android 应用程序
- android - 进度条不显示
- android - Android Kotlin 在 collpasingtoolbarlayout appbarlayout 中调整图像大小