jquery - Use search box for change image with javascript -


what should happen if search "halexer" using search box image

"http://site/avatar/200/nickname" (where nickname "halexer")

demo

javascript code:

$(document).ready(function() { var site_url = "http://site/"; var json = site_url+"json/"; var interval_beautifulcounter; var counterrequest;  $('#user-search-butt').click(function() {     var username = $('#user-search').val();     if (username !== '') {         displayusersinfo(username);     } else {         showalert('username cannot empty!', 'danger');     } }); function displayusersinfo(username) {{                     // title                     $('#modal-username-title').html(data.username);                     // avatar                     $('#modal-img-avatar').attr('src', site_url+'avatar/256/'+data.username);                     $('#modal-img-avatar').attr('alt', data.username+' avatar');                     $('#modal-img-avatar').attr('title', data.username+' avatar');                     $('#modal-input-avatar').val(site_url+'avatar/'+data.username);                     // skin                     $('#modal-img-skin').attr('src', site_url+'skin/256/'+data.username);                     $('#modal-img-skin').attr('alt', data.username+' skin');                     $('#modal-img-skin').attr('title', data.username+' skin');                     $('#modal-input-skin').val(site_url+'skin/'+data.username);                     // skin                     $('#modal-img-skin-back').attr('src', site_url+'skin-back/256/'+data.username);                     $('#modal-img-skin-back').attr('alt', data.username+' skin back');                     $('#modal-img-skin-back').attr('title', data.username+' skin back');                     $('#modal-input-skin-back').val(site_url+'skin-back/'+data.username);                     // buttons                     $('#modal-btn-user').attr('href', site_url+'user/'+data.username);                     $('#modal-btn-download').attr('href', site_url+'download/'+data.uuid);                     $('#modal-btn-change').attr('href', 'http://www.minecraft.net/skin/remote.jsp?url='+site_url+'skins/'+data.uuid+'.png');                     $('#user-info-modal').modal('show');                 }                 }             });     } else {         showalert('alert!', 'danger');     } }     return true; } }); 

in displayusersinfo function, shouldn't use data.username username.

also, since input field has id #username, think line

var username = $('#user-search').val(); 

should

var username = $('#username').val(); 

your jquery selector $('#user-search') doesn't seem refer in code posted.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -