scripts/menu.js
/**
 * Add a Drop-Down List Option to a specified optgroup, using a set of specified data for the Option Item's
 * Value and Text components.
 * The later an Option is discovered, the more recent it was entered into the database; we therefore
 * prepend it to the start of the optgroup, instead of appending it to the end
 * @param {Object} optgroup A jQuery encapsulated HTML optgroup tag, indicating the optgroup to add a new Option to
 * @param {String} optVal The value to use for the Option's Value attribute
 * @param {String} optTxt The value to use for the Option's Text component - the text that will be displayed
 *				   when the Drop-Down List is clicked
 */
Add a Drop-Down List Option to a specified optgroup, using a set of specified data for the Option Item's
Value and Text components.
The later an Option is discovered, the more recent it was entered into the database; we therefore
prepend it to the start of the optgroup, instead of appending it to the end
@param {Object} optgroup A jQuery encapsulated HTML optgroup tag, indicating the optgroup to add a new Option to
@param {String} optVal The value to use for the Option's Value attribute
@param {String} optTxt The value to use for the Option's Text component - the text that will be displayed
when the Drop-Down List is clicked
Add a Drop - Down List Option to a specified optgroup using a set of specified data for the Option Item ' s Value and Text components . The later an Option is discovered the more recent it was entered into the database ; we therefore prepend it to the start of the optgroup instead of appending it to the end @param { Object } optgroup A jQuery encapsulated HTML optgroup tag indicating the optgroup to add a new Option to @param { String } optVal The value to use for the Option ' s Value attribute @param { String } optTxt The value to use for the Option ' s Text component - the text that will be displayed when the Drop - Down List is clicked
function addToOptGroup(optgroup, optVal, optTxt) {
	var optionAlreadyExists = false;
	var optionToAdd = $("<option value='" + optVal + "'>" + optTxt + "</option>");
	optgroup.children().each(function() {
		if($(this).val() == optionToAdd.val())
			optionAlreadyExists = true;
	});
	if(!optionAlreadyExists)
		optgroup.prepend("<option value='" + optVal + "'>" + optTxt + "</option>");
}
function addToOptGroup ( optgroup , optVal , optTxt ) { var optionAlreadyExists = false ; var optionToAdd = $ ( "<option value='" + optVal + "'>" + optTxt + "</option>" ) ; optgroup . children ( ) . each ( function ( ) { if ( $ ( this ) . val ( ) == optionToAdd . val ( ) ) optionAlreadyExists = true ; } ) ; if ( ! optionAlreadyExists ) optgroup . prepend ( "<option value='" + optVal + "'>" + optTxt + "</option>" ) ; }
Add a Drop-Down List Option to a specified optgroup, using a set of specified data for the Option Item's
 Value and Text components.
Add a Drop - Down List Option to a specified optgroup using a set of specified data for the Option Item ' s Value and Text components .