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>

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

1
  • Is your question about how to assign var txt with a value comeing for a server-side variable? Commented Jan 25, 2012 at 11:44

1 Answer 1

1

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});});
Sign up to request clarification or add additional context in comments.

5 Comments

what does those '[]' surrounding DoThings() do?
Odds are that any autocomplete function is going to be ajaxy stuff and, being asynchronous, won't let you return anything.
@Quentin That's true, in ajax way, an callback function should be provide.
sorry, ive tried to update my method. i was hoping to avoid posting the whole thing and just grab a quick answer. but as ive said, i cant call the method from inside the jquery as i need to call it after keyup **note, if you have a pre built string, calling the method inside the juqery array works a treat
Sorry for the confusing edit updates - @user1168783 you should possibly update your question with the updated methods, or as xdazz suggests provide a jsfiddle sample you can both work on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.