user1168783
user1168783

Reputation: 13

Javascript passing variable to Jquery

<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>

but i want to move it to the page. im unsure how i send the variable "txt" to my jquery function

Upvotes: 0

Views: 121

Answers (1)

xdazz
xdazz

Reputation: 160973

Make the function have a return statement.

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

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

Upvotes: 1

Related Questions