我有currentItemId
。我想使用currentItemId
来获取元素的值(包含currentItemId
)。有可能吗?
目前我正在使用此代码:
function Custom_AddListMenuItems(m, ctx)
{
current = currentItemID;
var temp1 = document.getElementById('current');
alert(temp1);
CAMOpt(m,'AssetDetails (new window)','javascript:window.open(\'http://infpw03403:15000/Lists/Asset%20Repository/DispForm.aspx?ID='+temp1+'\')','/_layouts/images/LIST.GIF');
return false;
}
如果还有其他方法,请告诉我。
答案 0 :(得分:2)
您需要将变量(current)传递给getElementById而不是字符串'current'
var temp1=document.getElementById(current);
alert(temp1.value);
答案 1 :(得分:1)
在您的HTML页面中,元素必须具有其id =“currentItemId”。 然后只有你可以使用
var temp1 = document.getElementById(currentItemId).value;