It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

if (length<200) there is a problem

if (length<200) there is a problem

Postby erolkodak on Mon Jul 13, 2009 8:09 am

when I culculate length x width x thick there is no problem but I want; if length < 200 script calculate 200 and if width < 100 script calculate 100. there is no problem over width=100 and length=200 only when some people entering value under L=200 w=100 script suppose L=200 w=100.

thanks


<SCRIPT LANGUAGE="JavaScript">
function calculate_total()
{




var length = Number(document.
getElementById('calc').
length.value);





var width = Number(document.
getElementById('calc').
width.value);




var frame = Number(document.
getElementById('calc').
frame.options
[document.getElementById('calc...
frame.options.
selectedIndex].value);





var total = ((length * width) * frame;



switch (frame)
{
case 1.5:
total = total * 1;
break;
case 2:
total = total * 1;
break;
case 4:
total = total * 1;
break;
case 5:
total = total * 1;
break;
case 6:
total = total * 1;
break;
case 7:
total = total * 1;
break;
case 8:
total = total * 1;
break;
case 9:
total = total * 1;
break;

}

document.getElementById('calc'... = total + 0;
}
</script>

<form name="calc" id="calc">
LENDTH: <input type="text" name="length" onchange="calculate_total()" /><br />
WİDTH: <input type="text" name="width" onchange="calculate_total()" /><br />
<select name="frame" onchange="calculate_total()">
<option value="0" selected>ÇEŞİT SEÇİNİZ</option>
<option value="1.5">A</option>
<option value="2">B</option>
<option value="3">C</option>
<option value="4">D</option>
<option value="5">E</option>
<option value="6">F</option>
<option value="7">G</option>
<option value="8">H</option>
<option value="9">I</option>

</select>

<br />


<br />
TOTAL: <input id="total" name="total"/>
</form>
<script type="text/javascript">
function calculate_total()
{
var ttl = 1;
var len = document.forms['calc']['length'].value;
var wid = document.forms['calc']['width'].value;
var thick = document.forms['calc']['frame'].value;

if (len.length == 0)
{
return;
}

if (wid.length == 0)
{
return;
}

if (thick == 0)
{
return;
}

ttl = len * wid;
ttl *= 1;
switch (thick)
{
case "1.5":
ttl *= 30;
break;
case "2":
ttl *= 35;
break;
case "3":
ttl *= 40
break;
case "4":
ttl *= 50
break;
case "5":
ttl *= 60
break;
case "6":
ttl *= 70
break;
case "7":
ttl *= 80
break;
case "8":
ttl *= 90
break;
case "9":
ttl *= 100
break;
}

ttl /= 10000;
document.getElementById('total').value=ttl;


}
</script> :lol:
erolkodak
 
Posts: 1
Joined: Mon Jul 13, 2009 8:00 am

Who is online

Users browsing this forum: No registered users and 3 guests