javascript - HTML、JS 随机码生成器不工作
问题描述
所以我有这个类项目的代码,我有我的随机数生成器附加到当前流提交按钮,随机数生成器的结果应该放在水管信息占位符中。数字确实会出现一瞬间,但随后它们消失了。我究竟做错了什么?
function refreshPage() {
document.getElementById("ref").value = Math.floor(Math.random() * 70000) + 10000;
}
body {
background: #87CEEB;
color: #fff;
}
.header {
font-size: 20px;
text-align: center;
}
<form name="" class="">
<fieldset>
<div style="text-align:center; padding:.5em; margin-bottom:2em;">
<span style="border:1px solid #ccc;text-align:center; font-size:2em;background:#0099FF;padding:.5em; clear:both;">
National Water Company</span><br/>
</br><span style="border:1px solid #ccc;text-align:center; font-size:20px;background:#0099FF; padding:.5em; clear:both;">
System Damage Tracking, Water Loss Reporting. Leakage and Pipes Damage Reporting</span>
</div>
<div style="text-align:left; padding:.5em; margin-bottom:2em; width:40%; float:left;">
<span style="width:1em; font-size:1.5em;">Water Main Information</span>
<input id="ref" type="text" name="" style=" font-size:1.5em; width:160px;" /><br/>
<input type="submit" name="" style="font-size:1.5em;background:#0099FF" Value="current flow" onClick="refreshPage()" />
</div>
<div style="text-align:left; padding:.5em; margin-bottom:2em;">
<span style="width:10px; font-size:1.5em;">Customer Consumption </span>
<input type="text" name="" placeholder="Name" style=" font-size:1.5em; width:160px;" />
<input type="text" name="" placeholder="Address" style=" font-size:1.5em; width:160px;" />
<input type="text" name="" placeholder="Location" style=" font-size:1.5em; width:160px;" /><br/>
<input type="submit" name="" placeholder="" style="font-size:1.5em;background:#0099FF" Value="History" />
</div>
<div style="text-align:left; padding:.5em; margin-bottom:2em; width:50%; float:left;">
<span style="width:1em; font-size:1.5em;">Request Incident</span>
<input type="text" name="" placeholder="Name" style=" font-size:1.5em; width:150px;" />
<input type="text" name="" placeholder="Phone" style=" font-size:1.5em; width:150px;" />
<input type="text" name="" placeholder="Location" style=" font-size:1.5em; width:150px;" /><br/>
<input type="submit" name="" placeholder="" style="font-size:1.5em;background:#0099FF" Value="History" />
</div>
<div style="text-align:left; padding:.5em; margin-bottom:2em;">
<span style="width:1em; font-size:1.5em;">Differencing Data</span>
<input type="text" name="" placeholder="00,000 l" style=" font-size:1.5em; width:160px;" /><br/>
<input type="submit" name="" style="font-size:1.5em;background:#0099FF" Value="History" />
</div>
</fieldset>
</form>
解决方案
推荐阅读
- angular - 部署在本地 tomcat 服务器上的 Angular 应用程序的 url 在将 url 粘贴到浏览器的新选项卡上时不会加载组件
- python - 如何实现“tzinfo”以将当前 GMT 偏移到 EST(GMT -4:00)?
- openlayers - 如何修复“错误:无法为图层创建渲染器:未定义”?
- python-3.x - python json.dumps() 并将数据插入 mysql 1064 错误
- qt - 使用带有“父项:Overlay.overlay”的弹出窗口时的 QML 属性值传播
- javascript - Ionic/Firebase 图像选择器/裁剪和上传问题
- javascript - 使用 ng-change 函数更改变量的值
- ruby-on-rails - 访问类主体中的变量
- sql - 如何在 SQL 中创建特殊情况的 Intersect 子句?
- python - 为什么在循环中调用变量后会发生变化?