admin管理员组文章数量:1328037
I had a form which can edit some parameters and some are disabled.While uploading the edited form the disabled parameters returned null value,my code is as follows,
<div class="form-group col-md-6">
<label class="control-label required" for="name">Name</label>
<input type="text" readonly="readonly" disabled value="{user.name}}">
</div>
So while submitting the form ,should uses value "user.name" but it returns null since I provide disabled attribute.
I had a form which can edit some parameters and some are disabled.While uploading the edited form the disabled parameters returned null value,my code is as follows,
<div class="form-group col-md-6">
<label class="control-label required" for="name">Name</label>
<input type="text" readonly="readonly" disabled value="{user.name}}">
</div>
So while submitting the form ,should uses value "user.name" but it returns null since I provide disabled attribute.
Share Improve this question asked Aug 23, 2018 at 6:13 A.JRJA.JRJ 3711 gold badge6 silver badges17 bronze badges 3-
If you mark it as
disabled
then it won't pass along its value. Perhaps you can mark it asreadonly
if that fits your requirement? – Mohit Bhardwaj Commented Aug 23, 2018 at 6:19 -
@MohitBhardwaj Using readonly make the parameter similar to other where editing cursor is there but cant'edit.but my requirement is it should be look like
disabled
but it should pass its value – A.JRJ Commented Aug 23, 2018 at 6:24 -
1
how about using js to enable them just before sending ? you should be able to do it overiding
form.onsubmit
– jonatjano Commented Aug 23, 2018 at 6:27
2 Answers
Reset to default 5Use only readonly
instead of disabled
There is 2 choices :
<input type="text" value="{{user.name}}" readonly>
// In this case you can get post values
<input type="text" value="{{user.name}}" disabled>
// In this case you can not get post values
my requirement is it should be look like disabled but it should pass its value
You can use CSS to make it look disabled
.disabled {
background: #ccc;
cursor: not-allowed;
border-width: 1px;
}
<input type="text" readonly="readonly" class="disabled" />
<input type="password" readonly="readonly" class="disabled" />
<textarea readonly="readonly" class="disabled"></textarea>
本文标签: javascriptGetting Value from disabled attribute in htmlStack Overflow
版权声明:本文标题:javascript - Getting Value from disabled attribute in html - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742242597a2438927.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论