在表单上实时更新值

编程入门 行业动态 更新时间:2024-10-27 10:20:43
本文介绍了在表单上实时更新值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

与我的其他问题略有关系(已回答)这里,我是想要下面是可能的(它可能是非常基本的,但我有点noobish在JavaScript)!

所以我有2个输入字段,用户键入东西变成一种形式。他们按计算,然后功能总计了他们已经输入,然后分别计算1,2和3%的每个值。它看起来像这样:

输入1%的值 输入2%值 输入3%值 总计

我有办法能够实时更新表单吗?所以我的意思是,一旦用户输入一个值到一个字段,该功能会自动开始更新的值,如总等等?

感谢

Kiz

p>

解决方案

如果你想显示'realtime'(意思是用户键入)值,你可以使用键值: p>

  • http:/ /www.w3schools/jsref/event_onkeyup.asp (纯JavaScript)
  • api.jquery/keyup/ (用于 jquery)

回答:

最大

Slightly related to my other question (which was answered) here, I was wondering if the following was possible (it likely is and very basic but I'm a bit noobish at JavaScript)!

So I have 2 input fields where the user types something into a form. They press "calculate" and then the function totals up what they have entered and then calculates 1,2 and 3% for each value respectively. It looks something like this:

input 1%value input 2%value input 3%value total total

Is there a way for me to be able to update the form in real time? So by this I mean, as soon as the user enters a value into a field the function automatically starts updating the values such as total etc? How would I go about achieving this, can it be done purely in JavaScript?

Thanks

Kiz

解决方案

If you want to display 'realtime' (meaningly, as the user types) values, you can use the keyup values :

  • www.w3schools/jsref/event_onkeyup.asp (for pure javascript)
  • api.jquery/keyup/ (for jquery)

Regards,

Max

更多推荐

在表单上实时更新值

本文发布于:2023-11-10 10:31:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575111.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   实时

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!