我有一组 3 个输入字段,它们接受第一个和第二个输入并做一些数学运算以自动填充第三个输入。
我不希望看到第三个输入,但是使用 display:none
和 visibility:hidden
都返回 NaN
in out数据库。无论如何只隐藏输入,而不是自动填充的数据?
<div class="form-item webform-component webform-component-textfield webform-container-inline hs_total_donor_percent_change field hs-form-field total-field">
<label for="one">Total Donors Percent Change *</label>
<input id="edit-submitted-acquisition-percent-change"
class="form-text hs-input"
name="total_donor_percent_change"
readonly="readonly"
size="60"
maxlength="128"
type="text"
value=""
placeholder="0">
</div>
最佳答案
你可以使用一个隐藏的输入框:
<input id="inputOne" type="text"></input>
<input id="inputTwo" type="text"></input>
<input id="inputThree" type="hidden" value=""></input>
然后使用 jQuery,您可以在任何您喜欢的适当位置设置隐藏输入的值:
$('#inputThree').val("insert value here");
隐藏的输入很容易解释,元素是不可见的,但你可以使用 value
数据持久化属性。
编辑:值得注意的是,用户只需查看网页的源代码,就能看到元素的value
中的值。属性。
关于javascript - 隐藏输入但仍然让 JS 自动填充数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32097167/