function _(ele){ return document.getElementById(""+ele+""); } function check_code(code,output_id){ if (code.length < 4) { document.getElementById(output_id).innerHTML = ""; return; } else { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById(output_id).innerHTML = this.responseText; } }; xmlhttp.open("GET", "getcode.php?q=" + code, true); xmlhttp.send(); } } function tog(tog_state){ if(tog_state == '1'){ hide_list('number'); hide_list('prov'); hide_list('acnumber'); }else{ show_list('number'); show_list('prov'); show_list('acnumber'); } } function hide_list(ele){ _(ele).style.height = '0px'; _(ele).style.visibility = 'hidden'; _(ele).style.opacity = '0'; _(ele).style.borderWidth = '0'; _(ele).style.backgroundColor = ''; _(ele).style.color = ''; } function show_list(ele){ _(ele).style.height = '22px'; _(ele).style.visibility = 'visible'; _(ele).style.opacity = '1'; _(ele).style.borderWidth = '2px'; } function select_plan(plan,count=10){ _("plan_"+plan).checked = true; _("plan_list_reset").style.display='block'; var elements = document.getElementsByClassName('planitem'); for (var i in elements) { if (elements.hasOwnProperty(i)) { elements[i].style.height = '0px'; elements[i].style.visibility = 'hidden'; elements[i].style.opacity = '0'; elements[i].style.borderWidth = '0'; elements[i].style.backgroundColor = ''; elements[i].style.color = ''; } } _("plancont_"+plan).style.backgroundColor = '#E50011'; _("plancont_"+plan).style.color = '#FFFFFF'; _("plancont_"+plan).style.height = '20px'; _("plancont_"+plan).style.visibility = 'visible'; _("plancont_"+plan).style.opacity = '1'; _("plancont_"+plan).style.borderWidth = '2px'; // var i; // for (i = 1; i <= count; i++){ // if( plan != i){ // _("plancont_"+i).style.height = '0px'; // _("plancont_"+i).style.visibility = 'hidden'; // _("plancont_"+i).style.opacity = '0'; // _("plancont_"+i).style.borderWidth = '0'; // _("plancont_"+i).style.backgroundColor = ''; // _("plancont_"+i).style.color = ''; // }else{ // // _("plancont_"+i).style.backgroundColor = '#E50011'; // _("plancont_"+i).style.color = '#FFFFFF'; // } // } } function reset_plan_list(count){ var elements = document.getElementsByClassName('planitem'); for (var i in elements) { if (elements.hasOwnProperty(i)) { // elements[i].className = 'show-class'; elements[i].style.height = '20px'; elements[i].style.visibility = 'visible'; elements[i].style.opacity = '1'; elements[i].style.borderWidth = '2px'; } } // var i; // for (i = 1; i <= count; i++){ // // _("plancont_"+i).style.height = '20px'; // _("plancont_"+i).style.visibility = 'visible'; // _("plancont_"+i).style.opacity = '1'; // _("plancont_"+i).style.borderWidth = '2px'; // // } _("plan_list_reset").style.display='none'; } function paymant_notices(){ if( _("ongo_payment").value == 'cc' ){ _("payment_notices").innerHTML = ''; } if( _("ongo_payment").value == 'eft' ){ _("payment_notices").innerHTML = ''; } if( _("ongo_payment").value == 'ddr' ){ _("payment_notices").innerHTML = 'Please complete, sign and submit the Direct Debit Authority form HERE'; } } _("submit").disabled=true; var IDupload = false; function submit_check(){ if(_("TERMS").checked==true && IDupload == true ){ _("submit").disabled=false; }else{ _("submit").disabled=true; } } // Function that will allow us to know if Ajax uploads are supported function supportAjaxUploadWithProgress() { return supportFileAPI() && supportAjaxUploadProgressEvents() && supportFormData(); // Is the File API supported? function supportFileAPI() { var fi = document.createElement('INPUT'); fi.type = 'file'; return 'files' in fi; }; // Are progress events supported? function supportAjaxUploadProgressEvents() { var xhr = new XMLHttpRequest(); return !! (xhr && ('upload' in xhr) && ('onprogress' in xhr.upload)); }; // Is FormData supported? function supportFormData() { return !! window.FormData; } } // Actually confirm support if (supportAjaxUploadWithProgress()) { // Ajax uploads are supported! // Change the support message and enable the upload button var notice = document.getElementById('support-notice'); var uploadBtn = document.getElementById('upload-button-id'); notice.innerHTML = ""; uploadBtn.removeAttribute('disabled'); // Init the Ajax form submission //initFullFormAjaxUpload(); // Init the single-field file upload initFileOnlyAjaxUpload(); } function initFullFormAjaxUpload() { var form = document.getElementById('form_id'); form.onsubmit = function() { // FormData receives the whole form var formData = new FormData(form); // We send the data where the form wanted var action = form.getAttribute('action'); // Code common to both variants sendXHRequest(formData, action); // Avoid normal form submission return false; } } function initFileOnlyAjaxUpload() { var uploadBtn = document.getElementById('upload-button-id'); uploadBtn.onclick = function (evt) { var formData = new FormData(); // Since this is the file only, we send it to a specific location var action = 'upload.php'; // FormData only has the file var fileInput = document.getElementById('id_file'); var file = fileInput.files[0]; formData.append('our-file', file); formData.append('session_id', ''); if( document.forms['form_id'].id_file.value === "" ) { return false; } // Code common to both variants sendXHRequest(formData, action); } } // Once the FormData instance is ready and we know // where to send the data, the code is the same // for both variants of this technique function sendXHRequest(formData, uri) { // Get an XMLHttpRequest instance var xhr = new XMLHttpRequest(); // Set up events xhr.upload.addEventListener('loadstart', onloadstartHandler, false); xhr.upload.addEventListener('progress', onprogressHandler, false); xhr.upload.addEventListener('load', onloadHandler, false); xhr.addEventListener('readystatechange', onreadystatechangeHandler, false); // Set up request xhr.open('POST', uri, true); // Fire! xhr.send(formData); } // Handle the start of the transmission function onloadstartHandler(evt) { var div = document.getElementById('upload-status'); div.innerHTML = 'Upload started.'; } // Handle the end of the transmission function onloadHandler(evt) { var div = document.getElementById('upload-status'); div.innerHTML += '<' + 'br>File uploaded. Waiting for response.'; } // Handle the progress function onprogressHandler(evt) { var div = document.getElementById('progress'); var percent = evt.loaded/evt.total*100; percent = Math.round(percent); div.innerHTML = 'Progress: ' + percent + '%'; _("prog_bar").style.width = percent + '%'; } // Handle the response from the server function onreadystatechangeHandler(evt) { var status, text, readyState; try { readyState = evt.target.readyState; text = evt.target.responseText; status = evt.target.status; } catch(e) { return; } if (readyState == 4 && status == '200' && evt.target.responseText) { var status = document.getElementById('upload-status'); status.innerHTML = 'File Upload Sucsessfull'; IDupload = true; _('progress').innerHTML = ''; _("prog_bar").style.width = '0%'; submit_check(); _("id_file").value=''; // _("upload-button-id").type='hidden'; // var result = document.getElementById('result'); // result.innerHTML = '

The server saw it as:

' + evt.target.responseText + '
'; } }