HTML输入在更改时不会更新值属性 [英] HTML Input is not updating value attribute on change

查看:122
本文介绍了HTML输入在更改时不会更新值属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OOPS,由于name字段位于顶部,因此它是我正在测试的那个字段,事实证明这是唯一有问题的字段。必须与使用名称作为名称有关......




由于某些原因,我的输入标签表单在更改值属性时未更新查看实际元素(而不是JavaScript)。发布到服务器的数据是value属性的原始值,而不是文本框中的文本。



表单中的textareas工作正常,而且我有检查javascript被解雇的onchange,我找不到任何...请帮助!



以下是HTML:

 < form action =method =post> 
< div id =group-1class =group case>
< a class =标题打开>标题< / a>
< input name =editform [0] [class]value =casetype =hidden>
< input name =editform [0] [id]value =2type =hidden>
< div class =field>
< label>名称< / label>
< input class =textname =editform [0] [name]value =Mike Escarcagatype =text>
< / div>
< div class =field>
< label>标题< / label>
< input class =textname =editform [0] [title]value =General Managertype =text>
< / div>
<! - 对每个字段重复 - >
< div class =field>
< label>文字< / label>
< textarea class =ltextname =editform [0] [text]>
Blah HTML,还有更多...
< / textarea>
< / div>
< / div>
<! - 为表单中的每个组重复(editform [1],editform [2]等) - >
< / form>


解决方案

value属性包含 strong>值为一个输入,而不是实时值。



DOM值属性包含一个实时值。


OOPS, Since the "name" field was at the top it was the one I was testing with, and it turned out that was the only one with an issue. Must have something to do with using "name" as the name...


For some reason the input tags in my form are not updating the value attribute when they are changed view the actual element (not JavaScript). The data posted to the server is the original value of the "value" attribute, not the text in the textbox.

The textareas in the form work fine, and I have checked javascript fired "onchange" and I can't find any... Help please!

Here is the HTML:

<form action="" method="post">
<div id="group-1" class="group case">
  <a class="heading open">heading</a>
  <input name="editform[0][class]" value="case" type="hidden">
  <input name="editform[0][id]" value="2" type="hidden">
  <div class="field">
    <label>Name</label>
    <input class="text" name="editform[0][name]" value="Mike Escarcaga" type="text" >
  </div>
  <div class="field">
    <label>Title</label>
    <input class="text" name="editform[0][title]" value="General Manager" type="text" >
  </div>
  <!-- repeated for each field -->
  <div class="field" >
    <label >Text</label>
    <textarea class="ltext" name="editform[0][text]" >
      Blah HTML, and more blah...
    </textarea>
  </div>
</div>
<!-- repeated for each group in the form (editform[1], editform[2], etc.) -->
</form>

解决方案

The value attribute contains the default value for an input, not the live value.

The DOM value property contains a live value.

这篇关于HTML输入在更改时不会更新值属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆