嘿所有,我一直在這個問題上嘗試幾分鐘,我似乎無法弄清楚如何糾正它。當它涉及函數中的多個可變參數時,我傾向於最難做這樣的事情。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