Hi y'all,
I'm trying to create a customized context menu using the DHTML Popup
object. The HTML that makes up the body of the popup is created in a
variable named 'popCode'. Works like a charm, except when I call a
function in an onclick it gives an 'object expected' error. Here's the
popup function (dopopup) and the function I'm calling (renderData):
function dopopup(Value,F ield,x,y) {
popCode='';
popCode+='<html >\n<head>\n';
popCode+='<scri pt type="text/javascript"
src="xTable.js" ><\/script>\n';
popCode+='<\/head>\n<body>\n ';
popCode+='<tabl e style="border:1 pt solid #808080" bgcolor="#CCCCC C"
width="140" height="220" cellpadding="0"
cellspacing="1" oncontextmenu=\ "return false;\">\n';
popCode+='<STYL E TYPE="text/css">\n';
popCode+='td {font-family: Tahoma, Arial, Helvetica,
sans-serif;font-size: 8pt;font-style: normal;border:1 pt solid
#CCCCCC; background:#CCC CCC;}\n';
popCode+='.over {background:#33 66AF;color:#FFF FFF;border:1pt solid
#737B92}\n';
popCode+='<\/STYLE>\n';
popCode+='<scri pt type="text/javascript"
src="xTable.js" ><\/script>\n';
popCode+='<tr>< td'
popCode+=' onMouseover="cl assName=\'over\ ';"
onMouseout="cla ssName=\'\';" onClick="alert( \'' + Value +'\');">';
popCode+='Filte r op: '+Field+' is '+Value+'</td></tr>\n';
popCode+='<tr>< td';
popCode+=' onMouseover="cl assName=\'over\ ';"
onMouseout="cla ssName=\'\';" onClick="render Data(\'' + Field
+'\');">';
popCode+='Filte r op: '+Field+' is '+Value+'</td></tr>\n';
popCode+='</table>\n';
popCode+='<\/body>\n<\/html>\n';
var oPopupBody = oPopup.document .body;
oPopupBody.inne rHTML = popCode;
oPopup.show(x, y, 140, 220, document.body);
}
function renderData(filt erField){
alert("Joepie hij doet 't!");
alert(filterFie ld);
}
The onclick in the first td alerts the value properly. The onclick in
the second td makes a call to the function renderData, but since this
function isn't defined within the variable 'popCode', it gives the
error 'Object expected'. I tried linking to the javascript file these
functions are in, in the <HEAD> section, but that's not working
either. Either the <HEAD> section is completely ignored or I'm making
some mistake.
1 Does anyone know how to do this properly, passing the variables to
the renderData function? or
2 Does anyone know how to explicitly state in the second onclick where
the renderData function is to be found?
Please help me, for I am truly really frustrated...By e
Sharon
I'm trying to create a customized context menu using the DHTML Popup
object. The HTML that makes up the body of the popup is created in a
variable named 'popCode'. Works like a charm, except when I call a
function in an onclick it gives an 'object expected' error. Here's the
popup function (dopopup) and the function I'm calling (renderData):
function dopopup(Value,F ield,x,y) {
popCode='';
popCode+='<html >\n<head>\n';
popCode+='<scri pt type="text/javascript"
src="xTable.js" ><\/script>\n';
popCode+='<\/head>\n<body>\n ';
popCode+='<tabl e style="border:1 pt solid #808080" bgcolor="#CCCCC C"
width="140" height="220" cellpadding="0"
cellspacing="1" oncontextmenu=\ "return false;\">\n';
popCode+='<STYL E TYPE="text/css">\n';
popCode+='td {font-family: Tahoma, Arial, Helvetica,
sans-serif;font-size: 8pt;font-style: normal;border:1 pt solid
#CCCCCC; background:#CCC CCC;}\n';
popCode+='.over {background:#33 66AF;color:#FFF FFF;border:1pt solid
#737B92}\n';
popCode+='<\/STYLE>\n';
popCode+='<scri pt type="text/javascript"
src="xTable.js" ><\/script>\n';
popCode+='<tr>< td'
popCode+=' onMouseover="cl assName=\'over\ ';"
onMouseout="cla ssName=\'\';" onClick="alert( \'' + Value +'\');">';
popCode+='Filte r op: '+Field+' is '+Value+'</td></tr>\n';
popCode+='<tr>< td';
popCode+=' onMouseover="cl assName=\'over\ ';"
onMouseout="cla ssName=\'\';" onClick="render Data(\'' + Field
+'\');">';
popCode+='Filte r op: '+Field+' is '+Value+'</td></tr>\n';
popCode+='</table>\n';
popCode+='<\/body>\n<\/html>\n';
var oPopupBody = oPopup.document .body;
oPopupBody.inne rHTML = popCode;
oPopup.show(x, y, 140, 220, document.body);
}
function renderData(filt erField){
alert("Joepie hij doet 't!");
alert(filterFie ld);
}
The onclick in the first td alerts the value properly. The onclick in
the second td makes a call to the function renderData, but since this
function isn't defined within the variable 'popCode', it gives the
error 'Object expected'. I tried linking to the javascript file these
functions are in, in the <HEAD> section, but that's not working
either. Either the <HEAD> section is completely ignored or I'm making
some mistake.
1 Does anyone know how to do this properly, passing the variables to
the renderData function? or
2 Does anyone know how to explicitly state in the second onclick where
the renderData function is to be found?
Please help me, for I am truly really frustrated...By e
Sharon
Comment