Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

there is a problem with my script

Status
Not open for further replies.

erolkodak

MIS
Jul 13, 2009
1
TR
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>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top