也许是一个非常简单的问题。
如何输入此代码
<Query>
<Where>
<Eq>
<FieldRef Name="Judge_x0020_1" />
<Value Type="Text">mr. R. Sanches</Value>
</Eq>
</Where>
</Query>
代码区域中jscript的变量,其中mr。 R. Sanches写的。所以我的jScript包含一个动态文本变量,我想替换先生。 R.桑切斯。看看下面的JAVESCRIPT VAR:
我有jScript代码
<script src="/JavascriptMODS/jPointLoader.js"></script>
<script src="/JavascriptMODS/jPoint.userprofile.js"></script>
<SCRIPT type=text/javascript>
// Picks the userfield it is going to search with
var user = jP.getUserProfile();
var userinfspvalue = user.Department;
// removes the non breaking space at the end of the departmentfieldcontent
var removenonbreakingspace = String.fromCharCode(160);
userinfspvalue = userinfspvalue.replace(removenonbreakingspace,'');
</script>
Userinfspvalue是我想要使用的var。
在CAML查询中
<Query>
<Where>
<Eq>
<FieldRef Name="Judge_x0020_1" />
<Value Type="Text">Userinfspvalue</Value>
</Eq>
</Where>
</Query>
什么是jP.getUserProfile()?
代码(我没有创建它)。
/*
* name: jPoint.userprofile.js
* purpose: get user profile info from /_layouts/userdisp.aspx
* input: none
* visibility: public
* return: jP.UserProfile (object)
* jP.UserProfile.Name
* jP.UserProfile.Account
* jP.UserProfile.Title
* jP.UserProfile.EMail
* jP.UserProfile.Notes
* jP.UserProfile.AboutMe
* jP.UserProfile.Picture
* jP.UserProfile.Department
* jP.UserProfile.JobTitle
* jP.UserProfile.SipAddress
* jP.UserProfile.SIPAddress
*
* jP.UserProfile.FieldCount //count of fields
* jP.UserProfile.Fields //array of field names
* jP.UserProfile.Items[0].Name ... SipAddress
*
* use example:
* var usrprof = jP.getUserProfile(userID); //userID is optional
* var name = usrprof.Name;
* var email = usrprof.EMail;
* var dept = usrprof.Department;
*/
(function(jP) {
jP.getUserProfile = function (UserID) {
var ProfileURL = jP.SiteURL+"/_layouts/userdisp.aspx";
if(typeof UserID !== "undefined")
ProfileURL = ProfileURL + "?ID=" + UserID;
$.ajax( {
type: "GET", //jQuery ajax GET
async: false,
cache: false,
url: ProfileURL, //userprofile url
success: function(data){
var tags = $(data).find("h3 > a"); //look for anchor in h3 tag
if (tags.length > 0) {
var profile = {};
var fields = [];
var item = {};
$.each(tags, function(){
var name = this.name; //name attritbute
var td = $(data).find("tr a[name='"+name+"']").parent().parent(); //get label td
var labelname = jP.strip(td.text()); //get label text as field name
if (labelname == "Picture") {
//special handling for Picture field
//concat attribute alt and src together
var img = td.siblings().find("img");
var val = img.attr("alt") + ";#" + img.attr("src");
}
else {
//get text of next td cell
var val = $.trim(td.siblings().text());
}
var intname = name.substr(name.indexOf("_")+1); //internal field name
if ($.inArray(intname, fields)==-1) { //save as internal fieldname
fields.push(intname);
item[intname] = profile[intname] = val;
}
if ($.inArray(labelname, fields)==-1) { //save as label fieldname
fields.push(labelname);
item[labelname] = profile[labelname] = val;
}
});
//Set profile obj
profile["Fields"] = fields;
profile["FieldCount"] = fields.length;
profile["Items"] = [item];
//set UserProfile obj
jP["UserProfile"] = profile;
}
}
});
return (jP["UserProfile"])
}
})(jPoint);
答案 0 :(得分:1)
所以有一些事情。这个是客户端;浏览器执行这个JScript(因此我选择将它称为JavaScript ...好的调用重新标记它)
您正在使用名为jPoint的JavaScript库...但您正试图操纵CAML查询。
JPoint通过为您提供getUserProfile()
等功能来实践所谓的Information Hiding,但传统是我没有得到您可以操纵CAML的印象。事实上,从我在实现中看到的内容以及我在他们的网站上看到的内容来判断,我认为它甚至不是CAML查询,而只是screen scrapes来自个人资料页面的HTML。
总而言之,我认为你根本不想操纵CAML,而是需要找到合适的jPoint函数来使用。如果jPoint没有,你将不得不抛弃它并使用更传统的解决方案。
为什么你使用的是jPoint而不是传统或服务器端的东西?
答案 1 :(得分:-1)
尝试
var type = document.getElementById("testd"); // remember put your things in a div or equal
type.getAttribute('Type').value = "THE JAVASCRIPT VAR";