Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > รบกวนสอบถามเกี่ยวกับเรื่องกรอกค่าใน textbox แล้วส่งออกมาคำนวณ โดยไม่ต้อง submit



 

รบกวนสอบถามเกี่ยวกับเรื่องกรอกค่าใน textbox แล้วส่งออกมาคำนวณ โดยไม่ต้อง submit

 



Topic : 078787



โพสกระทู้ ( 21 )
บทความ ( 0 )



สถานะออฟไลน์




ตัวอย่างการแสดงผล
สวัสดีครับ พอดีผมอยากจะรบกวนสอบถามคือในภาพตัวอย่าง ถ้าผมอยากจะกรอกค่าในช่อง "จำนวน" พอกรอกเสร็จให้ส่งค่าจำนวนออกมานำมาคูณกับ "ราคา/หน่วย" แล้วให้อัพเดทค่าในช่อง จำนวนเงิน โดยที่ไม่ต้องมีการกด submit form น่ะครับไม่ทราบว่าใครพอจะแนะนำหน่อยได้ไหมครับ หรือใครพอจะมีกระทู้ให้ศึกษาบ้างครับ พอดีลองๆ search หาและลองทำตามหลายๆ กระทู้ที่ใกล้เคียงก็ยังไม่ได้น่ะครับ ขอบคุณล่วงหน้าครับ



Tag : PHP, JavaScript







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-05-22 19:04:27 By : tony78 View : 2636 Reply : 7
 

 

No. 1



โพสกระทู้ ( 1,127 )
บทความ ( 2 )



สถานะออฟไลน์


javascript-onkeydown






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-22 22:00:41 By : iieszz
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ดัดแปลงเอาครับ



Go to : อยากได้ code คำนวณค่าจาก sum ค่า textbox แบบอัตโนมัติ โดยใช้ javascript
Go to : JavaScript Sum Total Value From Textbox
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-23 06:23:58 By : mr.win
 

 

No. 3



โพสกระทู้ ( 3,155 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


Code (PHP)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>https://www.thaicreate.com/php/forum/078678.html</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>

<body>
<table cellpadding="2" cellspacing="0" border="1">
<tr style="text-align:center;"><td>ลำดับ</td><td>รายการ</td><td>จำนวน</td><td>ราคา</td><td width="120">รวมเงิน</td></tr>
<tr><td>1</td><td>Creating HTML5 Animations with Flash and Wallaby</td><td id="qty_td"><input type="text" name="qty[]" id="qty" size="5" /></td><td id="price">1,450</td><td id="line_total"></td></tr>
<tr><td>2</td><td>C# Database Basics</td><td id="qty_td"><input type="text" name="qty[]" id="qty" size="5" /></td><td id="price">1,050</td><td id="line_total"></td></tr>
<tr><td>3</td><td>jQuery Mobile: Up and Running</td><td id="qty_td"><input type="text" name="qty[]" id="qty" size="5" /></td><td id="price">1,250</td><td id="line_total"></td></tr>
</table>

<script>
function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
}

$("input#qty").blur(function(){
		var price =$(this).parent("#qty_td").next().text().replace("," , "");
		var qty = $(this).val();
		$(this).parent("#qty_td").next().next().text(numberWithCommas(parseFloat(price)*parseFloat(qty)));
});
</script>
</body>
</html>



ประวัติการแก้ไข
2012-05-23 10:10:18
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-23 10:00:56 By : sakuraei
 


 

No. 4



โพสกระทู้ ( 3,155 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


thaicreate-07878
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-23 10:07:47 By : sakuraei
 


 

No. 5



โพสกระทู้ ( 21 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณทุกๆ ท่านมากๆ เลยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-23 11:13:08 By : tony78
 


 

No. 6



โพสกระทู้ ( 386 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter

ผลลัพธ์ที่ได้ในช่องรวมเงิน ให้ค่าเป็น Nan
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
  <script src="http://code.jquery.com/jquery-latest.js"></script>
<!--POPUP หาคู่ค้า-->
<script type="text/javascript">
	function OpenBranch() {
		var myWindow=window.open("search_spare.php");
		if (!myWindow.opener) myWindow.opener = self;
		
	}
</script>

</head>

<body>
<form action="test2.php" method="post">
<table cellpadding="2" cellspacing="0" border="1">
<tr style="text-align:center;">
    <td>ลำดับ</td>
    <td>รายการ</td>
    <td>จำนวน</td>
    <td>ราคา</td>
    <td width="120">รวมเงิน</td>
</tr>
<?
$hdnMaxLine = 5;
for($x=1;$x<=$hdnMaxLine;$x++){ 
?> 

<tr>
    <td><?=$x;?></td>
    <td><input type="text" name="sp_code[]" id="sp_code" /><input type="button" VALUE="..." onClick="Javascript:OpenBranch();" /></td>
    <td id="qty_"><input type="text" name="qty[]" id="qty" size="5" /></td>
    <td id="price_"><input type="text" name="price[]" id="price" ></td>
    <td id="line_total"></td>
</tr>
<? } ?>
</table>
<input type="hidden" name="hdnMaxLine" value="5">
<input type="submit" value=" บันทึก ">
</form>

<script>
function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
}

$("input#qty").blur(function(){
		var price =$(this).parent("#qty_").next().text().replace("," , "");
		var qty = $(this).val();
		$(this).parent("#qty_").next().next().text(numberWithCommas(parseFloat(price)*parseFloat(qty)));
});
</script>
</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-11 15:03:25 By : PALM26
 


 

No. 7



โพสกระทู้ ( 3,155 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ตอบความคิดเห็นที่ : 6 เขียนโดย : PALM26 เมื่อวันที่ 2014-02-11 15:03:25
รายละเอียดของการตอบ ::
ลองแบบนี้น่ะครับ


Code (PHP)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
  <script src="http://code.jquery.com/jquery-latest.js"></script>
<!--POPUP หาคู่ค้า-->
<script type="text/javascript">
	function OpenBranch() {
		var myWindow=window.open("search_spare.php");
		if (!myWindow.opener) myWindow.opener = self;
		
	}
</script>

</head>

<body>
<form action="test2.php" method="post">
<table cellpadding="2" cellspacing="0" border="1">
<tr style="text-align:center;">
    <td>ลำดับ</td>
    <td>รายการ</td>
    <td>จำนวน</td>
    <td>ราคา</td>
    <td width="120">รวมเงิน</td>
</tr>
<?
$hdnMaxLine = 5;
for($x=1;$x<=$hdnMaxLine;$x++){ 
?> 

<tr>
    <td><?=$x;?></td>
    <td><input type="text" name="sp_code[]" id="sp_code" /><input type="button" VALUE="..." onClick="Javascript:OpenBranch();" /></td>
    <td id="qty_"><input type="text" name="qty[]" class="qty" size="5" /></td>
    <td id="price_"><input type="text" name="price[]" class="price" /></td>
    <td id="line_total"></td>
</tr>
<? } ?>
</table>
<input type="hidden" name="hdnMaxLine" value="5">
<input type="submit" value=" บันทึก ">
</form>

<script>
function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
}

$("input.qty, input.price").keyup(function(){
		if($(this).attr("class") == "price"){
			var price = $(this).val();
			var qty = $(this).parent("td").prev().find("input.qty").val();
		}else{
			var qty = $(this).val();
			var price = $(this).parent("td").next().find("input.price").val();
		}

		$(this).parents("tr").find("td:nth-child(5)").text(numberWithCommas(parseFloat(price)*parseFloat(qty)));
});
</script>
</body>
</html>


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-11 15:43:32 By : sakuraei
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รบกวนสอบถามเกี่ยวกับเรื่องกรอกค่าใน textbox แล้วส่งออกมาคำนวณ โดยไม่ต้อง submit
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่