Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jquery function help - passing variables for textbox id?

Status
Not open for further replies.

ochaos

Programmer
Sep 9, 2008
18
US
Hi there, I am new to jquery and trying to write one jquery function to do multiple things and either what I am trying to do isnt supported or I am doing it wrong, a little help would be awesome.

Here is my function as is and working.
Called by: $("#drop_player").click(onSelectRoster);
function onSelectRoster(){
var selected = $("#roster option:selected");
var output = "";
if(selected.val() != 0){
output = selected.text();
}
$("#rfa_drop").val(output);
}

What I am trying to do is change the output textbox based on a passed variable like this.
Called by: $("#drop_player").click(onSelectRoster("#rfa_drop"));
function onSelectRoster(test){
var selected = $("#roster option:selected");
var output = "";
if(selected.val() != 0){
output = selected.text();
}
$(test).val(output);
}

Can someone point me in the right direction.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top