troubleshooting Question

How do I get the value from a textbox and assign it to a hiddenField in JS, using Html helper hidden field cod? MVC4 ASP.NET

Avatar of bmanmike39
bmanmike39 asked on
ASP.NET.NET ProgrammingJavaScriptC#
4 Comments1 Solution59 ViewsLast Modified:
I have a textbox that I would like to assign the values to the hidden field, when i submit the form. How would I do this?  I'm using Html helper  and don't know how to 1, assign a id to it. And 2, how to access the textbox and put it in the hidden field.

Code:  js
<script type="text/javascript">
                    function gqt()
                        var x = document.getElementById("quantity").value;

Code: view
<form method="post" action="script">

                   @Html.Label("Quantity:") <input id="quantity" type="text" value="1"/>
                   @Html.Hidden("itemNumber", ViewData["numberId"].ToString())
                   @Html.Hidden("quantity", ????)

                   <input class="btn btn-danger" type="submit" value="Add Info" onclick="gqt()" />
Lokesh B R

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2015

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros