javascript - Input value hidden -
i have input:
<input id="tag1" type="text" name="tags" class="tags" value="@model.list" />
and want input value in hidden input, used this:
<input type="hidden" name="tag" value="tags" />
instead of getting true value of first input, string "tags"! can please tell me how obtain true value of first input in hidden input? thanks!
edit: it's submit page, user enters tags in #tag1 , when clicks on submit want send these tags controller, that's why i'm using hidden input... full code:
<form> <p> <input id="tag1" type="text" name="tags" class="tags" value="@model.list" onblur="setvalue()"; /></p> <script> $('#tag1').tagsinput({ // parameters here }); </script> <style> #wrapper { margin: 20px; } </style> <p> <input type="submit" value="create" /> <input type="hidden" name="taggg" id="tag2" /> <script type="text/javascript"> function setvalue() { document.getelementbyid("tag2").value = document.getelementbyid("tag1").value; } window.onload = setvalue; </script> </p> </form>
i don't understand why want copy value of 1 input field (albeit, hidden). if want do, try using below code.
the function attached onblur
event of input field set value of input field hidden field whenever loses focus.
the window.onload = setvalue
same on page load.
html
<input id="tag1" type="text" name="tags" class="tags" value="@model.list" onblur="setvalue();" /> <input type="hidden" name="tag" value="tags" id="tag1_hidden" /> <!-- note addition of id attribute -->
javascript
function setvalue() { document.getelementbyid("tag1_hidden").value = document.getelementbyid("tag1").value; } window.onload = setvalue;
Comments
Post a Comment