jquery - What is wrong in this javascript dropdown select function? -
i calling reusable function sets selected value dropdown. missing here??
function setdropdownvalue(dropdownid,selectedvalue){ $(dropdownid 'option').each(function(){ if ($(this).val().tolowercase()==selectedvalue.tolowercase()){ //found option looking for, want $(this).val(selectedvalue); } }); }
and calling like,
function setselectedsport(selsport,tempcount){ setdropdownvalue($("#sportid2"),selsport); }
i getting undefined error in $(dropdownid 'option').each(function(){
.. missing here??
edit:
after changing $('#'+dropdownid+' option').each(function(){
ecah() function doesnt seem executed.
looks you're missing concatenation operator , hash tag id. try:
$('#'+dropdownid+' option')