传递并在get方法上将javascript变量设置为值

时间:2011-03-02 17:47:59

标签: javascript jquery html

如何调用javascript变量在get函数中设置为值?

我有这段代码:

<script type="text/javascript">
    var imagelinks = $('div[name=content] a');  
    idno = imagelinks.attr('idno');
</script>

我希望在get函数中将idno设置为我的输入类型的值。这是代码:

<form method="GET" action="action.php">
    <input id="i1" name="i1" value=" //this is where i want "idno" to be passed">
</form>

帮忙!

2 个答案:

答案 0 :(得分:1)

你的意思是:

$('#i1').val(idno);

答案 1 :(得分:0)

<script type="text/javascript">
var imagelinks = $('div[name=content] a');  
idno = imagelinks.attr('idno');
document.getElementById('i1').value = idno;
</script>