



function setSelected(myForm) {
	//  This function will filter all select tags of a form
	// It will look for a hidden element with a 'previous' value
	// and it will select the previous option that was submitted
	// If there is no previous_ element, the script will fail
	//  Previous is a hidden field with a name = previous_ + select_name 	
	// Written for gratissms (place script at bottom of form)
	for (var i=0; i<myForm.elements.length; i++) {		
		// Filter select tags
		 if (myForm.elements[i].type == 'select-one') {
			select_name = myForm.elements[i].name;
			previous_name = 'previous_' + select_name;
			previous = myForm.elements[previous_name].value;			
			for (var x=0; x<myForm.elements[i].options.length; x++) {
				if (myForm.elements[i].options[x].value == previous) {
					myForm.elements[i].options[x].selected = 'True';
				}
			}
		}
	}
}

