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 > จำนวนของ createElement รบกวนขอคำแนะนำ และช่วยแก้ไข code ด้านล่างหน่อยครับ ผมไม่รู้ว่ามันผิดพลาดตรงไหน



 

จำนวนของ createElement รบกวนขอคำแนะนำ และช่วยแก้ไข code ด้านล่างหน่อยครับ ผมไม่รู้ว่ามันผิดพลาดตรงไหน

 



Topic : 045760

Guest




รบกวนขอคำแนะนำ และช่วยแก้ไข code ด้านล่างหน่อยครับ ผมไม่รู้ว่ามันผิดพลาดตรงไหน คือว่าติดปัญหาตรง ช่อง No. น่ะครับ พอคลิก add แล้วมันขึ้น 1 ซ้ำน่ะครับ ที่ถูกต้องมันน่าจะเป็น 2 น่ะครับ เพราะมันมี 1 ก่อนหน้านี้อยู่แล้วน่ะครับ ผมต้องแก้ไขตรงไหนครับ

<HTML>
<HEAD>
<TITLE>New Document</TITLE>
<script>
function addRowToTable()
{
var tbl = document.getElementById('datatable');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);

// Number Cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
//cellLeft.setAttribute('bgColor', '#CCCCCC');
cellLeft.setAttribute('align', 'center');
cellLeft.appendChild(textNode);


// P/N Cell
var cellRight1 = row.insertCell(1);
var el = document.createElement('input');
//cellRight1.setAttribute('align', 'center');
//cellRight1.setAttribute('bgColor', '#CCCCCC');
el.setAttribute('type', 'text');
el.setAttribute('name', 'txtPartNumber' + iteration);
el.setAttribute('id', 'txtPartNumber' + iteration);
el.setAttribute('size', '30');
cellRight1.appendChild(el);

document.getElementById('txtPartNumber' + iteration).onchange = function() {
ShowDescription('txtPartNumber' + iteration,'txtDescription' + iteration);
}

// Description Cell
var cellRight2 = row.insertCell(2);
var e2 = document.createElement('input');
//cellRight2.setAttribute('align', 'center');
//cellRight2.setAttribute('bgColor', '#CCCCCC');
e2.setAttribute('type', 'text');
e2.setAttribute('name', 'txtDescription' + iteration);
e2.setAttribute('id', 'txtDescription' + iteration);
e2.setAttribute('size', '30');
cellRight2.appendChild(e2);

// Quantity Cell
var cellRight3 = row.insertCell(3);
var e3 = document.createElement('input');
//cellRight3.setAttribute('align', 'center');
//cellRight3.setAttribute('bgColor', '#CCCCCC');
e3.setAttribute('name', 'qty' + iteration);
e3.setAttribute('id', 'qty' + iteration);
e3.setAttribute('cols', '42');
//e3.setAttribute('wrap','VIRTUAL');
cellRight3.appendChild(e3);

// UnitPrice Cell
var cellRight4 = row.insertCell(4);
var e4 = document.createElement('input');
var text = document.createTextNode("");
//cellRight4.setAttribute('align', 'center');
//cellRight4.setAttribute('bgColor', '#CCCCCC');
e4.setAttribute('type', 'text');
e4.setAttribute('name', 'UnitPrice' + iteration);
e4.setAttribute('id', 'UnitPrice' + iteration);
e4.setAttribute('size', '3');
cellRight4.appendChild(text);
cellRight4.appendChild(e4);


// Amount Cell
var cellRight5 = row.insertCell(5);
var e5 = document.createElement('input');
e5.setAttribute('type', 'text');
e5.setAttribute('name', 'amount' + iteration);
e5.setAttribute('id', 'amount' + iteration);
e5.setAttribute('size', '7');
//cellRight5.setAttribute('align', 'center');
//cellRight5.setAttribute('bgColor', '#CCCCCC');
//cellRight5.appendChild(document.createTextNode(""));
cellRight5.appendChild(e5);
}

function sumx()
{
var table = document.getElementById('datatable');
var total =0;
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {

document.formx.elements('amount'+i).value = document.formx.elements('qty'+i).value * document.formx.elements('UnitPrice'+i).value;
total = total + parseInt(document.formx.elements('amount'+i).value);
}

document.formx.elements('txtTotal').value = total;
}

function removeRowFromTable()
{
var tbl = document.getElementById('datatable');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}

</script>
</HEAD>
<BODY>
<form name="formx">
<table class="three" border="1" width="70%">
<tr>
<td width="5%" bgcolor="#FFC0FF"><b><p align="center">No.</b></p></td>
<td width="15%" bgcolor="#FFC0FF"><b><p align="center">รหัส</b></p></td>
<td width="20%" bgcolor="#FFC0FF"><b><p align="center">รายการ</b></p></td>
<td width="10%" bgcolor="#FFC0FF"><b><p align="center">จำนวน</b></p></td>
<td width="10%" bgcolor="#FFC0FF"><b><p align="center">หน่วยละ</b></p></td>
<td width="10%" bgcolor="#FFC0FF"><b><p align="center">จำนวนเงิน</b></p></td>
</tr>
<tbody id="datatable">
<tr>
<td width="5%"><p align="center">1</p></td>
<td width="15%"><input name="txtPartNumber0" id="txtPartNumber0" type="text" size="15" OnChange="JavaScript:ShowDescription('txtPartNumber0','txtDescription0');"></td>
<td width="20%"><input name="txtDescription0" id="txtDescription0" type="text" size="20"></td>
<td width="10%"><input name="qty0" id="qty0" type="text" size="10"</td>
<td width="10%"><input name="UnitPrice0" id="UnitPrice0" type="text" size="10"></td>
<td width="10%"><input name="amount0" id="amount0" type="text" size="10" onFocus="sumx()"></td>
<td width="10%"><img src="add.gif" height="16" border="0" onclick="addRowToTable('spare_part');"><img src="delete.gif" height="16" border="0" onclick="removeRowFromTable('spare_part');"></td>
</tbody>
</tr>
</table>
total =
<input type="text" name="txtTotal" size="7">
</form>
</BODY>
</HTML>



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-07-20 16:57:35 By : num View : 812 Reply : 3
 

 

No. 1

Guest


ไม่มีใครช่วยดูให้เลยหรอครับ






Date : 2010-07-21 10:10:45 By : num
 


 

No. 2

Guest


พี่ ๆ ชาว thaicreate ครับ ขอความกรุณาช่วยดู code หรือขอคำแนะนำหน่อยครับ ผมจนปัญญาจริง ๆ ครับ ไม่รู้ว่ามันผิดตรงไหนครับ รบกวนหน่อยครับ
Date : 2010-07-21 16:05:24 By : num
 

 

No. 3



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

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

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

<td width="5%"><p align="center">1</p></td>

ก็ fix ไว้เป็น 1 นี่ค่ะ
Date : 2010-07-21 17:11:18 By : ultrasiam
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : จำนวนของ createElement รบกวนขอคำแนะนำ และช่วยแก้ไข code ด้านล่างหน่อยครับ ผมไม่รู้ว่ามันผิดพลาดตรงไหน
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 01
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 อัตราราคา คลิกที่นี่