我正在尝试将三个变量(artistID
,albumID
和当前选定的值)传递给函数播放器,但每次尝试时都会出现错误:
var carry_else = 'actorID,movieID,this.value'
这是代码,因为我一直试图编辑var carry_else
但没有成功:
actorID = movie_select.substring(0, movie_select.indexOf(':'));
movieID = movie_select.substring(movie_select.indexOf(':')+1, movie_select.length);
// this line needs to be edited to var carry_else = 'actorID,movieID,this.value' but doing this doesn't work
var carry_else = 'this.value,this.value,this.value'
hstr+="<form><select size='"+count+"' onChange='parent.info(" + carry_else + ");'>";
我该如何解决这个问题?
答案 0 :(得分:1)
由于actorID和movieID似乎是字符串,为什么不将它们作为文字输入:
function escapeHtml(str) {
return str.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"');
};
function quoteString(str) {
return '"'+str.replace(/"/g,'\\"')+'"';
}
hstr+="<form><select size='"+count+"' onChange='parent.info("+escapeHtml(quoteString(actorID))+","+escapeHtml(quoteString(movieID))+",this.value);'>";
如果可用,我会使用JSON.stringify()
代替上面提到的quoteString
功能。