Javascript function of the day (JFOTD)

Wednesday, 15 June 2011 – 10:10

Doing some manipulation of selectboxes with the help of http://www.texotela.co.uk/code/jquery/select/. Using it to add a massive amount of options with the use of ajax.

$("#QueryResp").ajaxAddOption("./persons.xsp", {}, false, setOptionValue, [{"value":strResp}]);

Yes, I’m using xPages to feed the JSON to the function. Works very well with the added performance and cache possibilities of xpage “agents”.

To be able to set a default selected option I wrote a small function that is called when loading of options is complete.

function setOptionValue(arg) {
var $this = $(this);
$this.selectOptions(arg.value, true);
}

Very handy function to read url parameters as well;

function getURLParameter(name) {
return unescape(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]);
}

All with the help of jQuery of course.

Sorry, comments for this entry are closed at this time.