VinnyGuitara VinnyGuitara - 1 month ago 7
jQuery Question

Javascript function does not fire when I add a parameter

This function works:

function setIframeSrc()
{
var iframeSrc = "folder=999d146783e5452680943c9097453026&img=http%3A%2F%2Fuat%2Dishare%2Eihtech%2Ecom%2FStyle%20Library%2FMedia%20Player%2FVideoPreview%2Epng&title=1&lHome=1&lOwner=1";
var iframeBase = document.getElementById("videoFrame").src;
document.getElementById("videoFrame").src = iframeBase + iframeSrc;
}


and is called by this in another function:

$(xData.responseXML).SPFilterNode("z:row").each(function()
{
var ID = $(this).attr("ows_ID");
var Title = $(this).attr("ows_Title");
var URL = $(this).attr("ows_URL");
//var empName = $(this).attr("ows_EmpName");
//var jobtitle = $(this).attr("ows_JobTitle");
//var dept = $(this).attr("ows_Department");
alert(URL);
$("#myHTMLTable").append("<tr align='middle'>" +
"<td align='left'>"+ID+"</td>" +
"<td align='left'>"+Title+"</td>" +
"<td align='left'><a id='uri' href='#' onclick='return setIframeSrc()' >Link To Movie</a></td>" +
"</tr>");



});


When I try to add a parameter:

function setIframeSrc(URL)
{
var iframeSrc = "folder=999d146783e5452680943c9097453026&amp;img=http%3A%2F%2Fuat%2Dishare%2Eihtech%2Ecom%2FStyle%20Library%2FMedia%20Player%2FVideoPreview%2Epng&amp;title=1&amp;lHome=1&amp;lOwner=1";
var iframeBase = document.getElementById("videoFrame").src;
document.getElementById("videoFrame").src = iframeBase + iframeSrc;
}


and call it from getMyListData()

$(xData.responseXML).SPFilterNode("z:row").each(function()
{
var ID = $(this).attr("ows_ID");
var Title = $(this).attr("ows_Title");
var URL = $(this).attr("ows_URL");
//var empName = $(this).attr("ows_EmpName");
//var jobtitle = $(this).attr("ows_JobTitle");
//var dept = $(this).attr("ows_Department");
alert(URL);
$("#myHTMLTable").append("<tr align='middle'>" +
"<td align='left'>"+ID+"</td>" +
"<td align='left'>"+Title+"</td>" +
"<td align='left'><a id='uri' href='#' onclick='return setIframeSrc(URL)' >Link To Movie</a></td>" +
"</tr>");



});


The function fails to execute. Can I assign a parameter in the dynamic javascript? What am I doing wrong here

Answer
onclick='return setIframeSrc(" + URL + ")' 
Comments