我想输出只有文章如果authorsId = authorId
。函数返回一个列表 - 问题与过滤输出
除此之外,整个函数的工作正是我想要的,那就是:
的总体思路是,以限制只能访问自己的文章。
所以,我的问题是:如何限制结果仅显示由我们所在页面的所有者编写的文章(authorsId = authorId
)。
function ArticlesListReturn(returned) {
xml = returned.documentElement;
var rel = document.getElementById('related_category_articles');
rel.options.length = 0;
var status = getXMLData('status');
var title = '';
var id = '';
var authorid = '';
if (status == 0) {
alert("%%LNG_jsArticleListError%%" + errormsg);
} else {
var authorid = document.getElementById("authorid").value; // Serge
// authorsid = getNextXMLData('authors',x);
for (var x = 0; x < xml.getElementsByTagName('titles').length; x++) {
title = getNextXMLData('titles', x);
id = getNextXMLData('ids', x);
authorsid = getNextXMLData('authors', x);
alert(authorsid) // authors of each article - it returns the proper values
alert(authorid) // author of the page we are on - it returns the proper value
var count = 0;
rel.options[x] = new Option(title, id, authorid); // lign that returns results
title = '';
id = '';
authorid = '';
}
}
您仍然有一个松散的'rel.options' – mplungjan
@mplungjan我更新了。至于你关于getNextXMLData的问题,它与其他事情有关(一旦列表产生),我认为这与问题无关。 rel.options(不确定要理解)。 – Sergelie
'rel.options <<< needs to go - next line is var count = 0;' – mplungjan