Search code examples
javascriptphpjqueryhtmlhidden-field

How to set a value of one hidden field to another hidden field using jQuery?


I'm using PHP, Smarty, jQuery(jquery-1.7.1.min.js), AJAX, etc. Following is my HTML code:

<input type="hidden" id="que_id" name="que_id" value=76539 />

I'm having another input of type hidden as follows:

<input type="text" name="question_id" id="question_id" value=""/>

Now what I want to achieve is when the page loads completely, set the value of first input hidden field to the second hidden input field. How should I do this?


Solution

  • Simple:

    $(document).ready(function() {
        $("#question_id").val($("#que_id").val());
    });