var rURL = '/calc.php'; var READY_STATE_COMPLETE=4 function getHTTPRequestObject() { var xmlHttpRequest; if (typeof ActiveXObject != 'undefined') { xmlHttpRequest = new ActiveXObject('Microsoft.XMLHTTP'); } else if (typeof XMLHttpRequest != 'undefined') { xmlHttpRequest = new XMLHttpRequest(); } else { xmlHttpRequest = false; } return xmlHttpRequest; } var httpRequester = getHTTPRequestObject(); //Рабочий экземпляр класса XMLHttpRequest //выполняет асинхронный GET function makeAJAXCall(ajaxUrl){ if (httpRequester) { httpRequester.open("GET", ajaxUrl, true); httpRequester.onreadystatechange = processResponse; httpRequester.send(null); } /*location.href=ajaxUrl;*/ } function processResponse() { if (httpRequester.readyState == READY_STATE_COMPLETE) { if (httpRequester.status==200) { printToPage (""+httpRequester.responseText+"", 'calc_area'); document.getElementById('status_area').style.display = 'none'; } else { var message = "Problem retrieving data. requestStatus="+httpRequester.status+". Message="+httpRequester.statusText; printToPage (""+message+""); } } } //Выводим переданный HTML в элемент с id="result" function printToPage(value, id){ if(!id) id = 'status_area'; resultDiv = document.getElementById(id); resultDiv.innerHTML = value; resultDiv.style.display = ''; } function openCalc() { //alert(document.getElementById('calc_area')); var calc_area = document.getElementById('calc_area'); if(calc_area) { if(calc_area.style.display=='none') { makeRequest(); calc_area.style.display = ''; } else calc_area.style.display = 'none'; } } function makeRequest(UrlToGo) { printToPage ("Отправляется зарпос к серверу..."); makeAJAXCall(rURL+(UrlToGo && UrlToGo.length>0?'?'+UrlToGo:'')); } function makeCalculations1() { var ar_fields = Array('section', 'mark', 'width', 'length', 'thickness', 'count'); var loc_string = 'calculate1=yes'; for(fname in ar_fields) { if(elem=document.getElementById(ar_fields[fname])) loc_string = loc_string+'&'+elem.name+'='+elem.value; } makeRequest(loc_string); } function makeCalculations2() { var ar_fields = Array('section', 'mark', 'width1', 'length1', 'parameter1', 'parameter', 'thickness1', 'count', 'weight1', 'size1', 'size2'); var loc_string = 'calculate2=yes'; for(fname in ar_fields) { if(elem=document.getElementById(ar_fields[fname])) loc_string = loc_string+'&'+elem.name+'='+elem.value; } makeRequest(loc_string); } function changeParameter(name_val, param_id) { if(inp=document.getElementById(param_id)) inp.name = name_val; } function changeParameter1(name_val, param_id) { if(inp=document.getElementById(param_id)) inp.name = name_val; } function changeSection(section, just_loaded) { //alert('yes'); if(section=='list') value = 'Ширина'; else value = 'Диаметр'; if(elem=document.getElementById('label_width')) elem.innerHTML = value; if(div_lc=document.getElementById('list_params')) div_lc.style.display = section=='list' ? '' : 'none'; var ar_width = Array(); var ar_length = Array(); var ar_marks = Array(); ar_width['circle'] = Array(); ar_length['circle'] = Array(); ar_width['list'] = Array(); ar_length['list'] = Array(); ar_width['square'] = Array(); ar_length['square'] = Array(); ar_width['six'] = Array(); ar_length['six'] = Array(); if(!just_loaded) { if(width_section=document.getElementById("width")) { while(width_section.childNodes.length>0) width_section.removeChild(width_section.lastChild); for(i in ar_width[section]) { var option = document.createElement("option"); option.value = ar_width[section][i]; option.innerHTML = ar_width[section][i]; width_section.appendChild(option); } } if(length_section=document.getElementById("length")) { while(length_section.childNodes.length>0) length_section.removeChild(length_section.lastChild); for(i in ar_length[section]) { var option = document.createElement("option"); option.value = ar_length[section][i]; option.innerHTML = ar_length[section][i]; length_section.appendChild(option); } } s if(section_marks=document.getElementById("mark")) { while(section_marks.childNodes.length>0) section_marks.removeChild(section_marks.lastChild); for(i in ar_marks[section]) { var option = document.createElement("option"); option.value = i; option.innerHTML = ar_marks[section][i]; section_marks.appendChild(option); } } } } //changeSection('circle', true);