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 > วิธี sum ค่า textbox แบบ Multiple โดยใช้ JavaScript เขียนแบบใหนได้บ้างครับ รบกวนพี่ๆดูให้หน่อยครับ



 

วิธี sum ค่า textbox แบบ Multiple โดยใช้ JavaScript เขียนแบบใหนได้บ้างครับ รบกวนพี่ๆดูให้หน่อยครับ

 



Topic : 095882



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



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




รบกวนพี่ๆด้วยครับ ถ้าผมต้องการหาผลรวมจากช่อง AMOUNT(BAHT) โดย textbox name=txtpart_amount ให้แสดงผลที่ช่อง Total
ไม่ทราบว่าต้องเขียนโค๊ดแบบใหนอ่ะครับ

ผมอ้างอิงจาก https://www.thaicreate.com/php/forum/072984.html

ภาพที่1

Code (JavaScript)
<script language="javascript">

	function OpenPopup(intLine)
	{
		window.open('quotation_select.php?Line='+intLine,'myPopup','width=1300,height=450,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=10,top=100');
	}


	function CreateNewRow()
	{
		

		var intLine = parseInt(document.frmMain.hdnMaxLine.value);		
		intLine++;
		
			
		var theTable = document.getElementById("tbExp");
		var newRow = theTable.insertRow(theTable.rows.length)
		newRow.id = newRow.uniqueID

		var newCell
		
		//*** Column No ***//
		newCell = newRow.insertCell(0);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center>"+intLine+"</center>";

		//*** Column CustomerID ***//
		newCell = newRow.insertCell(1);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" STYLE=\"width:95%;\" NAME=\"txtpart_number_"+intLine+"\"  ID=\"txtpart_number_"+intLine+"\" VALUE=\"\"></center>";

		//*** Column part_description ***//
		newCell = newRow.insertCell(2);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" STYLE=\"width:98%;\" NAME=\"txtpart_description_"+intLine+"\"  ID=\"txtpart_description_"+intLine+"\" VALUE=\"\"></center>";

		//*** Column QTY ***//
		newCell = newRow.insertCell(3);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" STYLE=\"width:50%; text-align:right;\" NAME=\"txtQTY_"+intLine+"\" ID=\"txtQTY_"+intLine+"\"  VALUE=\"\"> Pc.</center>";
		
		//*** Column part_selling_price ***//
		newCell = newRow.insertCell(4);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\"STYLE=\"width:95%; text-align:right;\" NAME=\"txtpart_selling_price_"+intLine+"\" ID=\"txtpart_selling_price_"+intLine+"\"  VALUE=\"0.00\"></center>";
		
		//*** Columnpart_discount ***//
		newCell = newRow.insertCell(5);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" STYLE=\"width:75%; text-align:right;\" NAME=\"txtpart_discount_"+intLine+"\"  ID=\"txtpart_discount_"+intLine+"\" VALUE=\"0.00\"> %</center>";
	
			//*** Column part_amount ***//
		newCell = newRow.insertCell(6);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" STYLE=\"width:94%;  text-align:right;\" NAME=\"txtpart_amount_"+intLine+"\"  ID=\"txtpart_amount_"+intLine+"\" VALUE=\"0.00\"></center>";	

			//*** Column Add ***//
		newCell = newRow.insertCell(7);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		//newCell.setAttribute("OnClick", "OpenPopup('"+intLine+"')");
		newCell.innerHTML = "<center><INPUT TYPE=\"BUTTON\" NAME=\"btnPopup_"+intLine+"\"  ID=\"btnPopup_"+intLine+"\" VALUE=\"...\" OnClick=\"OpenPopup('"+intLine+"')\"></center>";	
	
		document.frmMain.hdnMaxLine.value = intLine;
		
		
	
	}
	
	function RemoveRow()
	{
		intLine = parseInt(document.frmMain.hdnMaxLine.value);
		if(parseInt(intLine) > 0)
		{
				theTable = document.getElementById("tbExp");				
				theTableBody = theTable.tBodies[0];
				theTableBody.deleteRow(intLine);
				intLine--;
				document.frmMain.hdnMaxLine.value = intLine;
		}	
	}	

	function GenerateRow()
	{
		var intRows = parseInt(document.frmMain.txtCount.value);
		for(i=0;i<intRows;i++)
		{
			 CreateNewRow();
		}
	}

	
</script>





Tag : PHP, MySQL, JavaScript









ประวัติการแก้ไข
2013-05-30 15:30:58
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-05-30 15:24:26 By : sodong View : 2322 Reply : 7
 

 

No. 1



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



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

ผมยังไม่ลองทีนะว่าได้มั้ย
Code (JavaScript)
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function(){      
      $("INPUT[name^=btnPopup_]").change(function(){
              var total = 0;
              $("INPUT[name^=btnPopup_]").each(function(){ total += parseFolat($(this).val()); });
              $("INPUT[name=total]").val(total);
      });
});
</script>







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-30 15:47:04 By : itpcc
 


 

No. 2



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



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


ขอบคุณมากครับพี่

แต่ถ้าใช้ Code (JavaScript) ที่ผมดพส เอามาจากพี่วิน จะแทรก เพิ่มตรงใหนยังไงได้บ้างครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-30 15:56:40 By : sodong
 

 

No. 3



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



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

โค๊ดไหนครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-30 16:12:52 By : itpcc
 


 

No. 4



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



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


Code (JavaScript) ที่ผมโพสอ่ะครับ เป็นการับค่ามาในรูปแบบนี้ เป็น multiple อ้างจาก https://www.thaicreate.com/php/forum/072984.html ซึ่งคล้ายกันมากเลย
แต่ถ้า ต้องการหาผลรวม ของตัวนี้

Code (JavaScript)
//*** Column part_amount ***//
newCell = newRow.insertCell(6);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" STYLE=\"width:94%;  text-align:right;\" NAME=\"txtpart_amount_"+intLine+"\"  ID=\"txtpart_amount_"+intLine+"\" VALUE=\"0.00\"></center>";  


โดยให้แสดงที่ ช่อง Total ไม่ทราบว่าต้องเขียนโค๊ดรูปแบบใหนอ่ะครับ


ประวัติการแก้ไข
2013-05-30 16:23:42
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-30 16:22:54 By : sodong
 


 

No. 5



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



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


รบกวนพี่ๆ ช่วยแนะนำโค๊ด ด้วยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-30 17:05:40 By : sodong
 


 

No. 6



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



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


ไม่มีใครมา test ของผมบ้างเลยเหรอครับ.... 5555 แนะนำผมหน่อย..... ผมงมมา 3 วันแล้วไม่มีวี่แววเลย
ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-30 17:47:36 By : sodong
 


 

No. 7



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

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

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

https://www.thaicreate.com/php/forum/089731.html#2

สมบูรณ์ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-01-26 07:58:53 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : วิธี sum ค่า textbox แบบ Multiple โดยใช้ JavaScript เขียนแบบใหนได้บ้างครับ รบกวนพี่ๆดูให้หน่อยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 05
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 อัตราราคา คลิกที่นี่