//Sets a new value to a field and submits the form - if given as parameter "NameOfFormToSubmit"
function SetHiddenValue(fieldname, fieldvalue, NameOfFormToSubmit) {
    $("#" + fieldname).val(fieldvalue);
    if (NameOfFormToSubmit != "") {
        $("#" + NameOfFormToSubmit).submit();
    }
}


// Deletes all fields and submits the form - if given as parameter "NameOfFormToSubmit"
function ClearAllFields(NameOfFormToSubmit) {
    for (var x = 0; x < document.forms.length; x++) { // loops through all the forms in the document, and finds all the checkboxes
        var form = document.forms[x];
        for (var i = 0; i < form.elements.length; i++) {
            form.elements[i].value = "";
        }
    }
  
    if (NameOfFormToSubmit != "") {
        $("#" + NameOfFormToSubmit).submit();
    }
}



