admin管理员组文章数量:1327968
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 pletely, set the value of first input hidden field to the second hidden input field. How should I do this?
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 pletely, set the value of first input hidden field to the second hidden input field. How should I do this?
Share Improve this question edited Jan 5, 2016 at 8:18 halfer 20.3k19 gold badges109 silver badges202 bronze badges asked Mar 6, 2014 at 4:51 PHPLoverPHPLover 13k51 gold badges172 silver badges321 bronze badges8 Answers
Reset to default 5Simple:
$(document).ready(function() {
$("#question_id").val($("#que_id").val());
});
Try,
$(document).ready(function(){
$(window).load(function(){
$('#question_id').val($('#que_id').val());
});
});
It's very simple. try this code:
$(function(){//ensure document is ready
$('#question_id').val($('#que_id').val());
});
Within your document ready, you can just grab the element using the ID selector and just use the .val()
method, which can both return and set the value.
$(document).ready(function(){
$('#question_id').val( $('#que_id').val() );
});
var first_hidden_Value = $('#que_id').val();
$('#question_id').val(first_hidden_Value);
You have to do this in document.ready()
;
put this code in header tag
$( document ).ready(function() {
var a = $('#que_id').val();
$('#question_id').val(a);
});
$(function(){
var hidden1 = $('#que_id').val();
$('#question_id').val(hidden1);
});
User this code
$(document).ready(function(){
var que_id = $('#que_id').val();
$('#question_id').val(que_id);
});
本文标签: javascriptHow to set a value of one hidden field to another hidden field using jQueryStack Overflow
版权声明:本文标题:javascript - How to set a value of one hidden field to another hidden field using jQuery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742252047a2440944.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论