嘿所有,我一直在这个问题上尝试几分钟,我似乎无法弄清楚如何纠正它。当它涉及函数中的多个可变参数时,我倾向于最难做这样的事情。javascript onclick函数字符串问题
下面是代码:
var tempString = "thePrompt('Are you sure you wish to delete this?', 'theDel('" + IDnum + "', '" + theTitle + "', \'" + temperDay + "\', \'" + temperMonth + "\', \'" + temperYear + "\', \'" + DDiff + "\')";
html +=
"<div id='theTable" + IDnum + "' class='fc-event fc-event-hori fc-corner-left fc-corner-right' style='position:absolute; margin-top: 15px; z-index:8;left:"+left+"px'><div id='apDEL' style='position:relative;width:0px;height:0px;z-index:1000; top:-13px; left:2px; float:left;'><img src='img/xCal.png' width='15' height='15' alt='' border='0' onclick=\"" + tempString + "\" /></div>" + (ETC ETC...)
我不断收到错误是这样的:
Error: missing) after argument list
Line: 1, Column: 68
Source Code:
thePrompt('Are you sure you wish to delete this posting?', 'theDel('105', '50 points for visiting us today!!!!', '13', '3', '2010', '2')
而且它指向 '105'。
一如既往,任何帮助都会很棒! :O)
大卫
编辑/ UPDATE
好了,现在我已经移出了一些东西,我得到它的工作(即发送值,在弹出的提示框,但对于一些原因,它不看我的功能我按下删除键后!这是因为,提示是主要的页面上,我是有工作的代码是一个iframe内。
function theDel(theID, theTitle, day, month, year, DDiff)
{
var tempString = "delClientE(" + theID + ", '" + theTitle + "', " + day + ", " + month + ", " + year + ", " + DDiff + ")";
parent.thePrompt('Are you sure you wish to delete this event?', tempString);
}
删除按钮值现在看像这样:
delClientE(110, 'sadfsadfsdf', 14, 3, 2010, 2); jQuery.prompt.close();
然而,即使把parent.delClientE犯规找到函数或者...我怎样才能把它从iframe中时,提示框是是么?
大卫
刚试过,雅各指出,但是我仍然得到同样的错误。错误:缺失)参数列表后 行:1,列:68 源代码: thePrompt('您确定要删除此?','theDel('105','50分今天访问我们! '','13','3','2010','2')') – StealthRT 2010-04-13 21:37:46
将其更改为您建议的最后一个给我的另一个错误: 错误:语法错误 行:1,列:9 源代码: thePrompt( – StealthRT 2010-04-13 21:57:55
是你的函数字符串中的参数吗?他们都是? – drusnov 2010-04-13 22:26:15