daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest May 17th, 2018 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. addEvent(window, 'load', init, false);
  3. function init() {
  4.  if (!Sarissa || !document.getElementById) return;
  5. var formElements = document.getElementsByTagName('form');
  6. for (var i = 0; i < formElements.length; i++) {
  7.  if (formElements[i].className.match(/\bajaxify\b/)) {
  8.  
  9.               addEvent(formElements[i], 'submit', submitRating, false);
  10.  
  11.           }
  12.  
  13.       }
  14.  
  15.   }
  16.  
  17.  
  18.  
  19.   function submitRating(e) {
  20.  
  21.        /* Cancel the submit event, and find out which form was submitted */
  22.  
  23.       knackerEvent(e);
  24.  
  25.       var target = window.event ? window.event.srcElement : e ? e.target : null;
  26.  
  27.       if (!target) return;
  28.  
  29.      
  30.  
  31.       /* Check if this form is already in the process of being submitted.
  32.  
  33.        * If so, don't allow it to be submitted again. */
  34.  
  35.       if (target.ajaxInProgress) return;
  36.  
  37.      
  38.  
  39.       /* Set up the request */
  40.  
  41.       var xmlhttp =  new XMLHttpRequest();
  42.  
  43.       xmlhttp.open('POST', 'rating-calculator.php', true);
  44.  /* The callback function */
  45.       xmlhttp.onreadystatechange = function() {
  46.  
  47.           if (xmlhttp.readyState == 4) {
  48.  
  49.               if (xmlhttp.status == 200)
  50.  
  51.                    
  52.  
  53.                    
  54.  
  55.                    addRatingFeedback(xmlhttp.responseXML, target);
  56.  
  57.                    
  58.  
  59.               else
  60.  
  61.                   target.submit();
  62.  
  63.           }
  64.  
  65.       }
  66.  
  67.             /* Send the POST request */
  68.  
  69.       xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  70.  
  71.       xmlhttp.send('age=' + target.elements['age3'].value + '&max_amount=' + target.elements['max_amount'].value + '&now_amount=' + target.elements['now_amount'].value + '&drawdown_years=' + target.elements['drawdown_years'].value + '&interest_rates=' + target.elements['interest_rates'].value + '&property_value3=' + target.elements['property_value3'].value + '&house_price_inflation=' + target.elements['house_price_inflation'].value);
  72.       var loadingImg = document.createElement('img');
  73.  
  74.       target.getElementsByTagName('p')[0].appendChild(loadingImg);
  75.  
  76.       target.ajaxInProgress = true;
  77.  
  78.   }
  79.  
  80.  
  81.  
  82.   function addRatingFeedback(responseXML, target) {
  83.  
  84.       alert('hello');
  85.  
  86.  
  87.       var loadingImg = target.getElementsByTagName('img')[0];
  88.  
  89.       loadingImg.parentNode.className += ' success';
  90.  
  91.       value1 = responseXML.getElementsByTagName('age')[0].firstChild.data ;
  92.       value3 = responseXML.getElementsByTagName('max_amount')[0].firstChild.data ;
  93.       value4 = responseXML.getElementsByTagName('now_amount')[0].firstChild.data ;
  94.       value5 = responseXML.getElementsByTagName('interest')[0].firstChild.data ;
  95.       value6 = responseXML.getElementsByTagName('cashreserved')[0].firstChild.data ;
  96.       value7 = responseXML.getElementsByTagName('newhouse')[0].firstChild.data ;
  97.       value8 = responseXML.getElementsByTagName('equityremaining')[0].firstChild.data ;
  98.       value9 = responseXML.getElementsByTagName('interest2')[0].firstChild.data ;
  99.  
  100. document.getElementById('pleasechange7').innerHTML = '<span style="font-size:16px;font-weight:bold;text-align:center;">£'+value7 +'</span>';
  101. document.getElementById('pleasechange8').innerHTML = '<span style="font-size:16px;font-weight:bold;text-align:center;">£'+value8 +'</span>';
  102.  
  103. target.ajaxInProgress = false;
  104.  
  105.  
  106.   }
  107.  
  108.   </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top