Manage Learn to apply best practices and optimize your operations.

Easily add content to your selectlist (drop down list)

If you want to add easy content to your selectlist (dropdown list) this is your tip.

If you want to add easy content to your selectlist (dropdown list) this is your tip. Simply use the code below. It simply transforms your selectlist into a field where you can add your value. After that it will transform back into a select list. "Long Live the Dom"

Add if(this.options[this.selectedIndex].text == 'Other...') selectOther(this); to the ONCHANGE event of the select list and make sure the select list has an Other... option. The script should do the rest.

function selectOther(list) {
	var input = document.createElement("INPUT");
	input.className = "select";
	input.type = "text";
	input.onblur = function() {
		var list = this.oldNode;
		list.options[list.options.length - 1] = new Option(this.value, "", true);
		list.options[list.options.length] = new Option("Other...");
		list.selectedIndex = list.options.length - 2;

		this.parentNode.replaceChild(list, this);
	};
	input.oldNode = list.parentNode.replaceChild(input, list);
}

Dig Deeper on Lotus Notes Domino Administration Tools

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

SearchDataCenter
SearchContentManagement
Close