Ну, за кодом-то дело не станет..
function updateOrder(){
var numWidth = parseCount( document.getElementById("width").value);
var numHeight = parseCount( document.getElementById("height").value);
var resPrint = calcCurt(numHeight, numWidth);
if (checkFreez()){
labelPrice1.value = resPrint[0];
}
else {
labelPrice1.value = resPrint[1];
}
labelOb.value = resPrint[2];
labelV.value = resPrint[3];
}
function checkFreez(){
if (document.getElementById("freez").checked)
return 1;
else return 0;
}
function getParam(num){
var curType = [];
curType[0]=["2x200,40%",0.2,0.16,162,172,80,0.0015,0.5];
curType[1]=["2С…200,80%",0.2,0.12,162,172,80,0.0015,0.5];
curType[2]=["3С…300,27%",0.3,0.26,295,305,85,0.003, 1];
curType[3]=["3С…300,53%",0.3,0.22,295,305,85,0.003, 1];
curType[4]=["3С…300,86%",0.3,0.18,295,305,85,0.003, 1];
curType[5]=["4С…400,20%",0.4,0.36,445,480,90,0.006, 2];
curType[6]=["4С…400,40%",0.4,0.32,445,480,90,0.006, 2];
curType[7]=["4С…400,60%",0.4,0.28,445,480,90,0.006, 2];
return curType[num];
}
function calcCurt(height, width){
var greb = 380;
var mont = 370;
makeType(height);
typeN = getType();
curType = getParam(typeN);
var polos = (width-curType[1])/curType[2]+1;
if (polos<0)polos = 0;
var poloso = Math.ceil(polos);
var pogm = height * poloso;
if (pogm<0)pogm = 0;
var pogm1=0;
if (pogm<50)
pogm1=pogm;
else {
if (pogm<100)
pogm1=50+(poloso-Math.floor(50/height))*height;
else
pogm1=100+(poloso-Math.floor(100/height))*height;
}
var pogm2 = Math.ceil(pogm1);
if (pogm2<0)pogm2 = 0;
var price1 = pogm2 * curType[3];
var price2 = pogm2 * curType[4];
var gprice = greb * width;
var plastPrice = curType[5] * poloso;
var mprice = mont * width;
var finalPrice1 = mprice + plastPrice + gprice + price1;
var finalPrice2 = mprice + plastPrice + gprice + price2;
var obTotal = Math.round(((curType[6] * pogm2)+(width*0.005))*100.0)/ 100.0;
var vTotal = Math.round(((curType[7] * pogm2)+(width * 1.5))*100)/ 100.0;
var result = [finalPrice1,finalPrice2, obTotal, vTotal];
return result;
}
function makeType(height) {
var radio = 0;
if (height>0 && height<=2.5){
if (!document.getElementById("case1")){
clearType();
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'id', 'case1');
radio.setAttribute( 'value', '0');
tmp = document.getElementById("curType");
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("2x200,40%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'value', '1');
radio.setAttribute( 'defaultChecked', 'true');
radio.setAttribute( 'Checked', 'true');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("2С…200,80%"));
}
}
else if (height <= 3.2 && height > 2.5) {
if (!document.getElementById("case2")){
clearType();
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'id', 'case2');
radio.setAttribute( 'value', '2');
tmp = document.getElementById("curType");
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("3С…300,27%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'value', '3');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("3С…300,53%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'value', '4');
radio.setAttribute( 'defaultChecked', 'true');
radio.setAttribute( 'Checked', 'true');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("3С…300,86%"));
}
}
else if (height <= 4 && height > 3.2) {
if (!document.getElementById("case3")){
clearType();
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'id', 'case3');
radio.setAttribute( 'value', '3');
tmp = document.getElementById("curType");
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("3С…300,53%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'value', '4');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("3С…300,86%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'value', '5');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("4С…400,20%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'value', '6');
radio.setAttribute( 'defaultChecked', 'true');
radio.setAttribute( 'Checked', 'true');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("4С…400,40%"));
}
}
else if (height <= 5 && height > 4) {
if (!document.getElementById("case4")){
clearType();
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'id', 'case4');
radio.setAttribute( 'value', '3');
tmp = document.getElementById("curType");
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("3С…300,53%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'value', '4');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("3С…300,86%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'value', '6');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("4С…400,40%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'defaultChecked', 'true');
radio.setAttribute( 'Checked', 'true');
radio.setAttribute( 'value', '7');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("4С…400,60%"));
}
}
else if (height > 5) {
if (!document.getElementById("case5")){
clearType();
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'id', 'case5');
radio.setAttribute( 'value', '5');
tmp = document.getElementById("curType");
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("4С…400,20%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'value', '6');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("4С…400,40%"));
radio = document.createElement('input');
radio.setAttribute( 'type', 'radio');
radio.setAttribute( 'name', 'Ztype');
radio.setAttribute( 'value', '7');
radio.setAttribute( 'defaultChecked', 'true');
radio.setAttribute( 'Checked', 'true');
tmp.appendChild( radio );
tmp.appendChild(document.createTextNode("4С…400,60%"));
}
}
var inputs = document.getElementsByName("Ztype");
var input_len = inputs.length;
for (var i = 0; i < input_len; i++) {
inputs[i].onclick = updateOrder;
}
}
function getType () {
var inputs = document.getElementsByName("Ztype");
var selectedValue = -1;
var input_len = inputs.length;
for (var i = 0; i < input_len; i++) {
if (inputs[i].checked)
{
selectedValue = inputs[i].value;
break;
}
}
return selectedValue;
}
function parseCount(countString) {
num = +countString;
return num;
}
function clearType() {
tmp = document.getElementById("curType");
while (tmp.firstChild) {
tmp.removeChild(tmp.firstChild);
}
}
function calcTotal(id) {
var prices = document.getElementsByClassName(id);
var prices_len = prices.length;
var total=0;
for( var i = 0; i < prices_len; ++i )
total += parseCount(prices[i].innerHTML);
return total;
}
function Add2Table() {
jQuery.noConflict();
jQuery("#zakazDiv").show('slow');
var type = getParam(getType());
var moroz = checkFreez();
if (!checkFreez()) moroz = "РґР°";
else
moroz = "нет";
jQuery( "<tr><td>"+width.value+"</td><td>"+height.value+"</td><td>"+type[0]+"</td><td>"+moroz+"</td><td class=\"priceTd\">"+labelPrice1.value+"</td><td class=\"VTd\">"+labelV.value+"</td><td class=\"OTd\">"+labelOb.value+"</td></tr>" ).insertBefore( "#zakaz > tbody > tr:last" );
document.getElementById ( "itogo" ).innerHTML = (calcTotal("priceTd") + " СЂСѓР±.");
document.getElementById ( "totalV" ).innerHTML = (calcTotal("VTd")+ "РєРі.");
document.getElementById ( "totalO" ).innerHTML = (calcTotal("OTd")+ "Рј. РєСѓР±.");
}