|
|
|
ช่วยดูโค๊ดไห้หน่อยคับ พอดีจะต้องส่งโปรเจค อยากได้วิธีคำนวณ total value ของ dropdownlist |
|
|
|
|
|
|
|
<html>
<head>
<title>Purchase | NR-Quick</title>
<table>
<form id="form1" name="form1" method="post" action="pcPurchase.php">
<tr>
<td height="32" align="right"><span class="style63">Product 1 :</span></td>
<td colspan="3" align="center"><label>
<select name="Product1" size="1" id="Product1">
<option value="N/A" selected="selected">N/A</option>
<option value="P001">P001 - Air filters</option>
<option value="P002">P002 - Air mass meter</option>
<option value="P003">P003 - Break systems</option>
<option value="P004">P004 - Cabin filters</option>
<option value="P005">P005 - Drive belts</option>
<option value="P006">P006 - Electric fuel pumps and intank module</option>
<option value="P007">P007 - Fuel filters</option>
<option value="P008">P008 - Glow plugs</option>
<option value="P009">P009 - Horns and fanfares</option>
<option value="P010">P010 - Ignitionn cables</option>
<option value="P011">P011 - ignition coils</option>
<option value="P012">P012 - Lighting technologies</option>
<option value="P013">P013 - Oil filters</option>
<option value="P014">P014 - Oxygen sensors</option>
<option value="P015">P015 - Spark plugs</option>
<option value="P016">P016 - Windshield wipers</option>
</select>
</label></td>
</tr>
<tr>
<td height="32" align="right"><span class="style63">Quantity :</span></td>
<td width="61" align="center"><select name="Quantity1" size="1" id="Quantity1">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select></td>
<td width="90" align="center"> </td>
<td align="center"> </td>
</tr>
<tr>
<td height="32" align="right"><span class="style63">Product 2 :</span></td>
<td colspan="3" align="center"><label>
<select name="Product2" size="1" id="Product2">
<option value="N/A" selected="selected">N/A</option>
<option value="P001">P001 - Air filters</option>
<option value="P002">P002 - Air mass meter</option>
<option value="P003">P003 - Break systems</option>
<option value="P004">P004 - Cabin filters</option>
<option value="P005">P005 - Drive belts</option>
<option value="P006">P006 - Electric fuel pumps and intank module</option>
<option value="P007">P007 - Fuel filters</option>
<option value="P008">P008 - Glow plugs</option>
<option value="P009">P009 - Horns and fanfares</option>
<option value="P010">P010 - Ignitionn cables</option>
<option value="P011">P011 - ignition coils</option>
<option value="P012">P012 - Lighting technologies</option>
<option value="P013">P013 - Oil filters</option>
<option value="P014">P014 - Oxygen sensors</option>
<option value="P015">P015 - Spark plugs</option>
<option value="P016">P016 - Windshield wipers</option>
</select>
</label></td>
</tr>
<tr>
<td height="32" align="right"><span class="style63">Quantity :</span></td>
<td align="center"><select name="Quantity2" size="1" id="Quantity2">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select></td>
<td align="center"> </td>
<td align="center"> </td>
</tr>
<tr>
<td height="32" align="right"><span class="style63">Product 3 :</span></td>
<td colspan="3" align="center"><label>
<select name="Product3" size="1" id="Product3">
<option value="N/A" selected="selected">N/A</option>
<option value="P001">P001 - Air filters</option>
<option value="P002">P002 - Air mass meter</option>
<option value="P003">P003 - Break systems</option>
<option value="P004">P004 - Cabin filters</option>
<option value="P005">P005 - Drive belts</option>
<option value="P006">P006 - Electric fuel pumps and intank module</option>
<option value="P007">P007 - Fuel filters</option>
<option value="P008">P008 - Glow plugs</option>
<option value="P009">P009 - Horns and fanfares</option>
<option value="P010">P010 - Ignitionn cables</option>
<option value="P011">P011 - ignition coils</option>
<option value="P012">P012 - Lighting technologies</option>
<option value="P013">P013 - Oil filters</option>
<option value="P014">P014 - Oxygen sensors</option>
<option value="P015">P015 - Spark plugs</option>
<option value="P016">P016 - Windshield wipers</option>
</select>
</label></td>
</tr>
<tr>
<td height="32" align="right"><span class="style63">Quantity :</span></td>
<td align="center"><select name="Quantity3" size="1" id="Quantity3">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select></td>
<td align="center"> </td>
<tr>
<td>
Total:<input type="text" id="total" value="0" size="5" />
</td>
</tr>
<script>
(function($)
{
var products =
{
N/A : 0,
P001 : 200,
P002 : 470,
P003 : 330,
P004 : 250,
P005 : 400,
P006 : 360,
P007 : 230,
P008 : 430,
P009 : 250,
P010 : 370,
P011 : 620,
P012 : 300,
P013 : 400,
P014 : 440,
P015 : 500
}
var qty =
{
0 : 0,
1 : 1,
2 : 2,
3 : 3,
4 : 4,
5 : 5,
6 : 6,
7 : 7,
8 : 8,
9 : 9,
10 : 10
}
$("#Product1").change(function(){calc_and_show_total();})
$("#Product2").change(function(){calc_and_show_total();})
$("#Product3").change(function(){calc_and_show_total();})
$("#Quantity1").change(function(){calc_and_show_total();})
$("#Quantity2").change(function(){calc_and_show_total();})
$("#Quantity3").change(function(){calc_and_show_total();})
function calc_and_show_total()
{
var Product1 = products[$("#Product1").val()];
var Product2 = products[$("#Product2").val()];
var Product3 = products[$("#Product3").val()];
var Quantity1 = qty[$("#Quantity1").val()];
var Quantity2 = qty[$("#Quantity2").val()];
var Quantity3 = qty[$("#Quantity3").val()];
$("#total").val('$' + (Product1*Quantity1)+(Product2*Quantity2)+(Product3*Quantity3));
}
calc_and_show_total();
})(this.jQuery);
</script>
<td align="center"> </td>
</tr>
<tr>
<td height="65" align="right"> </td>
<td align="right"><input type="submit" name="BSubmit" id="BSubmit" value="Submit" /></td>
<td align="left"><input type="reset" name="BReset" id="BReset" value="Reset" /></td>
<td align="center"> </td>
</tr>
</table>
<br>
</form>
</table>
</body>
</html>
Tag : - - - -
|
|
|
|
|
|
Date :
2012-07-12 22:33:27 |
By :
nrs |
View :
960 |
Reply :
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คำนวณแบบไหนครับ Capture หน้าจอมาให้ดูหน่อยครับ
|
|
|
|
|
Date :
2012-07-12 22:58:58 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เลือก product แระ quantity แร้วอยากให้ที่คำนวนมาโชว์ในช่อง TOTAL อ่ะคับ
ขอบคุนคับ
|
|
|
|
|
Date :
2012-07-12 23:27:46 |
By :
nrs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตรง N/A เปลี่ยนเป็น 'N/A' นะคะ
แล้ว ต้อง เรียกสคริป Jquery เข้ามาใช้งานด้วยค่ะ
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script> ใส่บรรทัดนี้ข้างใต้ <table> แล้วลองรันดูใหม่ดูนะคะ
|
|
|
|
|
Date :
2012-07-12 23:42:54 |
By :
Th@iDev |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>Purchase | NR-Quick</title>
<table>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<form id="form1" name="form1" method="post" action="pcPurchase.php">
<tr>
<td height="32" align="right"><span class="style63">Product 1 :</span></td>
<td colspan="3" align="center"><label>
<select name="Product1" size="1" id="Product1">
<option value="N/A" selected="selected">N/A</option>
<option value="P001">P001 - Air filters</option>
<option value="P002">P002 - Air mass meter</option>
<option value="P003">P003 - Break systems</option>
<option value="P004">P004 - Cabin filters</option>
<option value="P005">P005 - Drive belts</option>
<option value="P006">P006 - Electric fuel pumps and intank module</option>
<option value="P007">P007 - Fuel filters</option>
<option value="P008">P008 - Glow plugs</option>
<option value="P009">P009 - Horns and fanfares</option>
<option value="P010">P010 - Ignitionn cables</option>
<option value="P011">P011 - ignition coils</option>
<option value="P012">P012 - Lighting technologies</option>
<option value="P013">P013 - Oil filters</option>
<option value="P014">P014 - Oxygen sensors</option>
<option value="P015">P015 - Spark plugs</option>
<option value="P016">P016 - Windshield wipers</option>
</select>
</label></td>
</tr>
<tr>
<td height="32" align="right"><span class="style63">Quantity :</span></td>
<td width="61" align="center"><select name="Quantity1" size="1" id="Quantity1">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select></td>
<td width="90" align="center"> </td>
<td align="center"> </td>
</tr>
<tr>
<td height="32" align="right"><span class="style63">Product 2 :</span></td>
<td colspan="3" align="center"><label>
<select name="Product2" size="1" id="Product2">
<option value="N/A" selected="selected">N/A</option>
<option value="P001">P001 - Air filters</option>
<option value="P002">P002 - Air mass meter</option>
<option value="P003">P003 - Break systems</option>
<option value="P004">P004 - Cabin filters</option>
<option value="P005">P005 - Drive belts</option>
<option value="P006">P006 - Electric fuel pumps and intank module</option>
<option value="P007">P007 - Fuel filters</option>
<option value="P008">P008 - Glow plugs</option>
<option value="P009">P009 - Horns and fanfares</option>
<option value="P010">P010 - Ignitionn cables</option>
<option value="P011">P011 - ignition coils</option>
<option value="P012">P012 - Lighting technologies</option>
<option value="P013">P013 - Oil filters</option>
<option value="P014">P014 - Oxygen sensors</option>
<option value="P015">P015 - Spark plugs</option>
<option value="P016">P016 - Windshield wipers</option>
</select>
</label></td>
</tr>
<tr>
<td height="32" align="right"><span class="style63">Quantity :</span></td>
<td align="center"><select name="Quantity2" size="1" id="Quantity2">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select></td>
<td align="center"> </td>
<td align="center"> </td>
</tr>
<tr>
<td height="32" align="right"><span class="style63">Product 3 :</span></td>
<td colspan="3" align="center"><label>
<select name="Product3" size="1" id="Product3">
<option value="N/A" selected="selected">N/A</option>
<option value="P001">P001 - Air filters</option>
<option value="P002">P002 - Air mass meter</option>
<option value="P003">P003 - Break systems</option>
<option value="P004">P004 - Cabin filters</option>
<option value="P005">P005 - Drive belts</option>
<option value="P006">P006 - Electric fuel pumps and intank module</option>
<option value="P007">P007 - Fuel filters</option>
<option value="P008">P008 - Glow plugs</option>
<option value="P009">P009 - Horns and fanfares</option>
<option value="P010">P010 - Ignitionn cables</option>
<option value="P011">P011 - ignition coils</option>
<option value="P012">P012 - Lighting technologies</option>
<option value="P013">P013 - Oil filters</option>
<option value="P014">P014 - Oxygen sensors</option>
<option value="P015">P015 - Spark plugs</option>
<option value="P016">P016 - Windshield wipers</option>
</select>
</label></td>
</tr>
<tr>
<td height="32" align="right"><span class="style63">Quantity :</span></td>
<td align="center"><select name="Quantity3" size="1" id="Quantity3">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select></td>
<td align="center"> </td>
<tr>
<td>
Total:<input type="text" id="total" value="0" size="5" /><br>
<div id="xtotal"></div>
</td>
</tr>
<script>
(function($)
{
var products =
{
'N/A' : 0,
P001 : 200,
P002 : 470,
P003 : 330,
P004 : 250,
P005 : 400,
P006 : 360,
P007 : 230,
P008 : 430,
P009 : 250,
P010 : 370,
P011 : 620,
P012 : 300,
P013 : 400,
P014 : 440,
P015 : 500
}
var qty =
{
0 : 0,
1 : 1,
2 : 2,
3 : 3,
4 : 4,
5 : 5,
6 : 6,
7 : 7,
8 : 8,
9 : 9,
10 : 10
}
$("#Product1").change(function(){calc_and_show_total();})
$("#Product2").change(function(){calc_and_show_total();})
$("#Product3").change(function(){calc_and_show_total();})
$("#Quantity1").change(function(){calc_and_show_total();})
$("#Quantity2").change(function(){calc_and_show_total();})
$("#Quantity3").change(function(){calc_and_show_total();})
function calc_and_show_total()
{
var Product1 = products[$("#Product1").val()];
var Product2 = products[$("#Product2").val()];
var Product3 = products[$("#Product3").val()];
var Quantity1 = qty[$("#Quantity1").val()];
var Quantity2 = qty[$("#Quantity2").val()];
var Quantity3 = qty[$("#Quantity3").val()];
var a1 = Product1*Quantity1;
var a2 = Product2*Quantity2;
var a3 = Product3*Quantity3;
var extotal = a1 + a2 + a3;
$("#total").val(extotal.toFixed(2));
//$("#total").html('$' + (Product1*Quantity1)+(Product2*Quantity2)+(Product3*Quantity3));
}
calc_and_show_total();
})(this.jQuery);
</script>
<td align="center"> </td>
</tr>
<tr>
<td height="65" align="right"> </td>
<td align="right"><input type="submit" name="BSubmit" id="BSubmit" value="Submit" /></td>
<td align="left"><input type="reset" name="BReset" id="BReset" value="Reset" /></td>
<td align="center"> </td>
</tr>
</table>
<br>
</form>
</table>
</body>
</html>
อันนี้หนูแก้ไขให้มันถูกต้อง ให้ + กันได้ +ฟิกทศนิยมไว้ 2 ตำแหน่งนะคะ
|
|
|
|
|
Date :
2012-07-12 23:50:52 |
By :
Th@iDev |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|