var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
function getContactPhone(username, objID) {
var obj = document.getElementById(objID);
xmlhttp.open("GET", "/names.nsf/GetOfficePhone?OpenAgent&username=" + username);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
obj.value = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
So I have the onBlur event for the contact field set to getContactPhone(document.forms[0].contact.value,'contact_phone'); so that the contact's phone number is looked up in the Public Address Book whenever the user tabs out of the field. The agent I created, GetOfficePhone, returns the user's phone number I want with 2 print statements:
Print "Content-type: text/plain"
Print doc.OfficePhoneNumber(0)
This technique could definitely be expanded to do full blown @DbColumn and @DBLookup functions.
Created 6/29/2005 9:25:13 AM email | website
After slapping myself over stupid ACL mistakes on my test, I got it to work like a charm in IE. No go in Firefox or Netscape though until I set the "ID" in the HTML properties tab of the phone field. Will blog on this later.
Created 6/30/2005 2:41:46 AM email | website
Nice work. A complete implementation of a Javascript DBLookup and a DBColumn function can be found here { Link }
Created 6/30/2005 11:04:10 AM email | website
Matt has posted a link to a tip i had posted on Search Domino.
That eventually was selected as Tip of the Month and i won an iPod Mini.
cheers !!
Ashish
Created 4/20/2008 12:43:05 PM email | website
Good work. Easy and convenient.