Switch statement in jQuery not working -
i writing little jquery function changes value of form field when user changes value of drop down list.
my function changing data works reason not "switching". can shed light?
here code:
$('#linktype').change(function(){ var thistype = $('#linktype').val(); switch(thistype){ case 'facebook': changeurl("http://facebook.com/"); break; case 'twitter': changeurl("http://twitter.com/"); break; } }); function changeurl(value){ $('input[id="link"]').val(value) ; };
facebook
should string literal 'facebook'
$('#linktype').change(function(){ var thistype = $('#linktype').val(); switch(thistype){ case 'facebook':
else need have variable called facebook
string value
var facebook = 'facebook' $('#linktype').change(function(){ var thistype = $('#linktype').val(); switch(thistype){ case 'facebook':
Comments
Post a Comment