James Rose Posted August 17, 2009 Share Posted August 17, 2009 I have a situation where I need to replace a function dynamically The function is usually: showItemDetails('"+iRow+"','1','"+iID1+"')" grdSelectItems.addRow(iRow,["<a href='#' title='"+sToolTip1+"' style='color:"+sColor+";font-family:Arial;font-weight:bold;font-size:9pt;text-decoration:none;' onclick=\"showItemDetails('"+iRow+"','1','"+iID1+"');\">"+sItem1+"</a>) However I sometimes need to call the function showVendorClosed(iID); I tried placing the first function in it's own string but that died a horrible death: var sFunction = "showItemDetails('"+iRow+"','1','"+iID1+"')" grdSelectItems.addRow(iRow,["<a href='#' title='"+sToolTip1+"' style='color:"+sColor+";font-family:Arial;font-weight:bold;font-size:9pt;text-decoration:none;' onclick=\'"+sFunction+";\">"+sItem1+"</a>) Thoughts? Link to comment Share on other sites More sharing options...
0 ProChefChad Posted August 17, 2009 Share Posted August 17, 2009 correct me if I'm wrong, but I don't think you need the quotes or the parameters.... instead try: var sFunction = showItemDetails; Link to comment Share on other sites More sharing options...
0 Antaris Veteran Posted August 18, 2009 Veteran Share Posted August 18, 2009 Looks like this could be a problem: onclick=\'" That single quote, together with your function string will end up like this: onlick='showItemDetails('...')' Replace that with this: onclick=\"" + sFunction + "\" That help? Link to comment Share on other sites More sharing options...
0 James Rose Posted August 18, 2009 Author Share Posted August 18, 2009 Replace that with this: onclick=\"" + sFunction + "\" That help? Yes, that helped. Thank you very much! I owe you one. Link to comment Share on other sites More sharing options...
Question
James Rose
I have a situation where I need to replace a function dynamically
The function is usually:
showItemDetails('"+iRow+"','1','"+iID1+"')"
grdSelectItems.addRow(iRow,["<a href='#' title='"+sToolTip1+"' style='color:"+sColor+";font-family:Arial;font-weight:bold;font-size:9pt;text-decoration:none;' onclick=\"showItemDetails('"+iRow+"','1','"+iID1+"');\">"+sItem1+"</a>)
However I sometimes need to call the function showVendorClosed(iID);
I tried placing the first function in it's own string but that died a horrible death:
var sFunction = "showItemDetails('"+iRow+"','1','"+iID1+"')"
grdSelectItems.addRow(iRow,["<a href='#' title='"+sToolTip1+"' style='color:"+sColor+";font-family:Arial;font-weight:bold;font-size:9pt;text-decoration:none;' onclick=\'"+sFunction+";\">"+sItem1+"</a>)
Thoughts?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts