2012-01-25 122 views
0
<script type="text/javascript"> 

function DoThings() 
{ 
var txt = txtbox.value; 

txt = /* passed info from code behind */ 
} 


$(function() { var Tags=[ txt ]; $("txtbox2").autocomplete({source: Tags});}); 

</script> 

但我想将它移动到页面。即时通讯不知如何发送变量“TXT”到我的jQuery功能Javascript传递变量到Jquery

+0

是你的问题,关于如何分配var txt值来服务器端变量? – deostroll

回答

1

使该函数有一个返回语句。

function DoThings() { 
    var txt = txtbox.value; 
    txt = /* passed info from code behind */ 
    return txt; //return it. 
} 

$(function() { 
    var Tags=[DoThings()]; $("#txtbox2").autocomplete({source: Tags});}); 
+0

围绕'DoThings()'做的'[]'是做什么的? – gdoron

+0

@gdoron这是一个数组。 – xdazz

+0

很可能是任何自动完成功能都将成为ajaxy的东西,而且是异步的,不会让你返回任何东西。 – Quentin