Home > DeveloperSection > Forums > Input value hidden using HTML and JavaScript
Jeet Verma
Jeet Verma

Total Post:110

Posted on    August-16-2013 6:49 AM

 VB Script VB Script 

 1 Reply(s)
 1725  View(s)
Rate this:
Hi developers!

I have this input:

<input id="tag1" type="text" name="tags" class="tags" value="@Model.list" />

and I want to get this input value in a hidden input, so I used this:

<input type="hidden" name="tag" value="tags" />

Instead of getting the true value of the first input, I only get the string "tags"! Can you please tell me how to obtain the true value of the first input in my hidden input?


shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Posted on    August-17-2013 6:30 AM

Hi Jeet!

I don't understand why you would want to copy the value of one input field to another (albeit, hidden). But if that is what you want to do, try using the below code.

The function attached to the onblur event of the input field would set the value of the input field to the hidden field whenever it loses focus.

The window.onload=setValue; will do the same on page load.


<input id="tag1" type="text" name="tags" class="tags" value="@Model.list" onblur="setValue();" />

<input type="hidden" name="tag" value="tags" id="tag1_hidden" />


function setValue() {

    document.getElementById("tag1_hidden").value = document.getElementById("tag1").value;


window.onload = setValue;

Best of luck!

Don't want to miss updates? Please click the below button!

Follow MindStick