javascript - Onclick window.location with parameter passed -


i trying retrieve records database , append each of them can displayed.

i figured out there syntax error somewhere in particular line, part image appended. clueless how append correctly image link can clicked on go next page parameter arr[i]itemid passed.

$("#wallcontentset").append("<b>" + arr[i].categoryname + "</b><br/>" + arr[i].itemname + "<br/>" + arr[i].price + "<br/>" + arr[i].soldstatus + "<br/>" + "<a href='#' onclick="window.location='viewtheitem.html?itemid=" + arr[i].itemid + "'"> + <img src='" + serverurl() + "/images/" + arr[i].imagefile + "'height='150'></a><br/><hr>"); 

can me out?

i changed code displayed below nothing happens when image appended , displayed clicked on:

enter code here $("#wallcontentset").append("<b>" + arr[i].categoryname + "</b><br/>" + arr[i].itemname + "<br/>" + arr[i].price + "<br/>" + arr[i].soldstatus + "<br/>" + "<a href='#' onclick=\"window.location='viewtheitem.html?itemid=" + arr[i].itemid + "\"><img src='" + serverurl() + "/images/" + arr[i].imagefile + "'height='150'></a><br/><hr>"); 

if @ end of code see have quotation mark problem

+ "<a href='#' onclick="window.location='viewtheitem.html?itemid=" + arr[i].itemid + "'"> + <img src='" + serverurl() + "/images/" + arr[i].imagefile + "'height='150'></a><br/><hr>"); 

you start new string " use same sign in onclick end string. either have use ' instead of " or escape quotation mark. 1 way be:

+ "<a href='#' onclick=\"window.location='viewtheitem.html?itemid=" + arr[i].itemid + "\"> + <img src='" + serverurl() + "/images/" + arr[i].imagefile + "'height='150'></a><br/><hr>");  

i hope solves problem.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -