Below is the code that I am using with Jquery to pass a value when a hyperlink is selected on sharepoint disp form.
for(var i=0;i<retval.length;i++)
{
strHTML = strHTML + "<a href='url.aspx?ID= '+retval[i]+' &Source= url'>" + retval[i] + "</a>";
strHTML = strHTML + " ";
}
strHTML = strHTML + "</div>";
$("textarea[Title='Test']").closest("span").find("iframe[Title='Rich Text Editor']").contents().find("body").html(strHTML);
Its unable to read the value in retval[i], its breaking right at ID. Is the syntax wrong?
If you want the variable to evaluate, it needs to be outside of the quotes (as you did with the actual hyperlink’s text):
However, I would look at using
encodeURIComponentbefore placing it within a URL:Also, try to avoid including spaces in the URL (make sure the variable, equal sign (
=) and value are close together). Also, given thehrefattribute’s value is surrounded by single quotes (') you want to avoid using them in the middle of the URL (e.g. don’t surround the ID’s value within the URL with').