hidden-fields

Set value of hidden field in a form using jQuery's “.val()” doesn't work

江枫思渺然 提交于 2019-11-26 17:09:46
I've been trying to set the value of a hidden field in a form using jQuery, but without success. Here is a sample code that explains the problem. If I keep the input type to "text", it works without any trouble. But, changing the input type to "hidden", doesn't work ! <html> <head> <script type="text/javascript" src="jquery.js"> </script> <script type="text/javascript"> $(document).ready(function() { $("button").click(function() { $("input:text#texens").val("tinkumaster"); }); }); </script> </head> <body> <p> Name: <input type="hidden" id="texens" name="user" value="texens" /> </p> <button>

ASP.Net MVC Html.HiddenFor with wrong value

可紊 提交于 2019-11-26 12:06:28
I'm using MVC 3 in my project, and I'm seeing a very strange behavior. I'm trying to create a hidden field for a particular value on my Model, the problem is that for some reason the value set on the field does not correspond to the value in the Model. e.g. I have this code, just as a test: <%:Html.Hidden("Step2", Model.Step) %> <%:Html.HiddenFor(m => m.Step) %> I would think that both hidden fields would have the same value. What I do is, set the value to 1 the first time I display the View, and then after the submission I increase the value of the Model field by 1. So, the first time I

Set value of hidden field in a form using jQuery&#39;s “.val()” doesn&#39;t work

喜夏-厌秋 提交于 2019-11-26 05:15:50
问题 I\'ve been trying to set the value of a hidden field in a form using jQuery, but without success. Here is a sample code that explains the problem. If I keep the input type to \"text\", it works without any trouble. But, changing the input type to \"hidden\", doesn\'t work ! <html> <head> <script type=\"text/javascript\" src=\"jquery.js\"> </script> <script type=\"text/javascript\"> $(document).ready(function() { $(\"button\").click(function() { $(\"input:text#texens\").val(\"tinkumaster\"); }

ASP.Net MVC Html.HiddenFor with wrong value

﹥>﹥吖頭↗ 提交于 2019-11-26 02:50:24
问题 I\'m using MVC 3 in my project, and I\'m seeing a very strange behavior. I\'m trying to create a hidden field for a particular value on my Model, the problem is that for some reason the value set on the field does not correspond to the value in the Model. e.g. I have this code, just as a test: <%:Html.Hidden(\"Step2\", Model.Step) %> <%:Html.HiddenFor(m => m.Step) %> I would think that both hidden fields would have the same value. What I do is, set the value to 1 the first time I display the