javascript - 我想创建一个简单的输入框,然后在您键入时计算 80%,但不使用表单

标签 javascript forms input

如果我不使用表单,我不知道如何从输入框中获取值...
所以我想复制以下内容但不使用表单标签...

<form action="#" name="myconvert">
100% of value = 
<input type="text" name="percent100" 
onkeyup=" document.myconvert.percent80.value = Math.round((0.8 * document.myconvert.percent100.value)*100)/100" />
so 80% = <input type="text" name="percent80" disabled />

请帮忙

最佳答案

<input type="text" name="percent100"  
onkeyup=" document.getElementById('percent80').value = Math.round((0.8 * document.getElementById('percent100').value)*100)/100" /> 
so 80% = <input type="text" name="percent80" disabled /> 

关于javascript - 我想创建一个简单的输入框,然后在您键入时计算 80%,但不使用表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4277298/

相关文章:

javascript - 如何获取回调函数的所有参数

javascript - 在 jQuery 的 GET 请求中使用发送按钮

javascript - 如果未聚焦于表单,则捕获删除键

javascript - 如何将 if 语句从警报更改为文本

javascript - Animate Opacity 与其他 Transform 函数异步

javascript - 具有 Marionette View 的主干关系示例

django - 如何为 Django 管理模型添加实例表单设置初始数据?

javascript - 单选表单值未显示?

input - CodeMirror 6,如何在输入/更新/更改事件中获取编辑器值?

javascript - `this` 内部格式化函数