Change an image on a html web page using javascript depending on an ID -
i new javascript , trying display image changes depending on id user types in.
below have declared variable "icon" store values of url + icon id + .png complete url :
icon = "http://ddragon.leagueoflegends.com/cdn/6.2.1/img/profileicon/" + summonericon + ".png"
an example of variable contain is: "http://ddragon.leagueoflegends.com/cdn/6.2.1/img/profileicon/14.png"
i use information in variable display on html page, when user types in username, javascript should return image matches id user has submitted.
these images stored @ url displayed above, not stored locally.
thanks reading question.
use jquery hook change event on input dictate id , pull value icon variable.
html
<input type="text" name="userid" id="id />
js
function getvals() { var icon = $( "#id" ).val(); } $( "input" ).change( getvals ); getvals();
you'll have tweak getvals function re-renders image displaying, should point in right direction.
Comments
Post a Comment