jquery - How to use text from the url query string to populate the image name in the image src path? -


i new js , teaching myself amazing people on site. code on site have worked out how populate text on web page parameters pulled query string in url, cannot work out how use same parameters populate file name in image path.

example url: http://www.mywebpage.com/editors.aspx?config=pagename&firstname=joe&lastname=bloggs

what have far works populate text on page:

            <script type="text/javascript">                $(document).ready(function(){                function geturlvars()               {                   var vars = [], hash;                   var hashes = window.location.href.slice(window.location.href.indexof('?') + 1).split('&');                   for(var = 0; < hashes.length; i++)                   {                       hash = hashes[i].split('=');                       vars.push(hash[0]);                       vars[hash[0]] = hash[1];                   }                   return vars;               }                var brokerfirstname = geturlvars()["firstname"];               var brokerlastname = geturlvars()["lastname"];                $('.brokerfirstname').replacewith(decodeuri(brokerfirstname));               $('.brokerlastname').replacewith(decodeuri(brokerlastname));                 });                </script>                <html>               <div class="detailstext"><span class="brokerfirstname">first name</span>&nbsp;<span class="brokerlastname">last name</span>               <img src="/library/profileimages/????????????????.jpg">               </div>   

how firstname , lastname src path image name, eg, src="/library/profileimages/joebloggs.jpg"?

many help.

give img tag id select image jquery , use .attr() so:

$(#imgid).attr("src", "/library/profileimages/" + brokerfirstname + brokerlastname + ".jpg") 

(replace 'imgid' id gave img tag)


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -