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 > จากโค้ดในตัวอย่างที่ Admin ได้ทำเอาไว้ ผมสามารถเพิ่ม ปุ่ม ลบ เฉพาะ row นั้นๆได้ไหมครับ



 

จากโค้ดในตัวอย่างที่ Admin ได้ทำเอาไว้ ผมสามารถเพิ่ม ปุ่ม ลบ เฉพาะ row นั้นๆได้ไหมครับ

 



Topic : 121190



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



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




https://www.thaicreate.com/community/javascript-passing-send-data-popup-to-main-page.html

จาก ตัวอย่างนี้ สมมุติ ผมเพิ่ม row มา 5 แถว แล้วที่นี้ ผม อยาก ลบ row ที่ 3 เลย
โดยที่ไม่ต้องกด ปุ่ม - ตามโค้ดที่ทำไว้แล้ว ให้ขึ้นไปถึง row ที่ต้องการจะลบ

สั้นๆก็คือ อยากลบ Row ที่เพิ่มมา แบบกำหนด ได้อะครับ
ผมต้องเขียน function ยังไงครับ T^T



Tag : PHP, HTML/CSS, JavaScript







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-02-03 00:46:33 By : makdonal View : 629 Reply : 4
 

 

No. 1



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



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

ไปใช้ jquery จะง่ายกว่านี้ 555 อันนี้ผมยอมไม่เก่ง javascript






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-02-03 01:23:29 By : progamer2000
 


 

No. 2



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



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


ผมก็พึ่งเริ่ม ศึกษา ตอนแรกก็ Java script ยิ่งศึกษายิ่ง งง แต่พอเจอ Jquery สบายขึ้นมาหน่อย แต่ก็ใช้ไม่เป็นอยู่ดี 555
รอพี่ Admin มาช่วย ><"
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-02-03 01:31:57 By : makdonal
 

 

No. 3



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



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

Code (PHP)
<html>
  <head>
    <title>ThaiCreate.Com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>

  <script language="javascript">

    function OpenPopup(intLine)
    {
      window.open('getData.php?Line='+intLine,'myPopup','width=650,height=200,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
    }

    function CreateSelectOption(ele)
    {
      var objSelect = document.getElementById(ele);
      var Item = new Option("", ""); 
      objSelect.options[objSelect.length] = Item;
<?php
while($objResult=mysql_fetch_array($objQuery)){
  ?>
            var Item = new Option("<?php echo $objResult["CountryName"];?>", "<?php echo $objResult["CountryCode"];?>"); 
            objSelect.options[objSelect.length] = Item;
  <?php
}
?>
        }

    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\" SIZE=\"5\" NAME=\"txtCustomerID_"+intLine+"\"  ID=\"txtCustomerID_"+intLine+"\" VALUE=\"\"></center>";

          //*** Column Name ***//
          newCell = newRow.insertCell(2);
          newCell.id = newCell.uniqueID;
          newCell.setAttribute("className", "css-name");
          newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"txtName_"+intLine+"\"  ID=\"txtName_"+intLine+"\" VALUE=\"\"></center>";

          //*** Column Email ***//
          newCell = newRow.insertCell(3);
          newCell.id = newCell.uniqueID;
          newCell.setAttribute("className", "css-name");
          newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"txtEmail_"+intLine+"\" ID=\"txtEmail_"+intLine+"\"  VALUE=\"\"></center>";
		
          //*** Column Country Code ***//
          newCell = newRow.insertCell(4);
          newCell.id = newCell.uniqueID;
          newCell.setAttribute("className", "css-name");
          newCell.innerHTML = "<center><SELECT NAME=\"txtCountryCode_"+intLine+"\" ID=\"txtCountryCode_"+intLine+"\"></SELECT></center>";
          //*** Create Option ***//
          CreateSelectOption("txtCountryCode_"+intLine)
		
          //*** Column Budget ***//
          newCell = newRow.insertCell(5);
          newCell.id = newCell.uniqueID;
          newCell.setAttribute("className", "css-name");
          newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"txtBudget_"+intLine+"\"  ID=\"txtBudget_"+intLine+"\" VALUE=\"\"></center>";
	
          //*** Column Used ***//
          newCell = newRow.insertCell(6);
          newCell.id = newCell.uniqueID;
          newCell.setAttribute("className", "css-name");
          newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"txtUsed_"+intLine+"\"  ID=\"txtUsed_"+intLine+"\" VALUE=\"\"></center>";	

          //*** Column 7 ***//
          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>";	
          
          //*** Column 7 ***//
          newCell = newRow.insertCell(8);
          newCell.id = newCell.uniqueID;
          newCell.setAttribute("className", "css-name");
          //newCell.setAttribute("OnClick", "OpenPopup('"+intLine+"')");
          newCell.innerHTML = "<center><INPUT TYPE=\"BUTTON\" NAME=\"btnDel_"+intLine+"\"  ID=\"btnDel_"+intLine+"\" VALUE=\"-\" OnClick=\"RemoveRowID('"+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 RemoveRowID(intLine)
        {
//          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;
          }	
        }	    
  </script>
  <body OnLoad="CreateNewRow();">
    <form name="frmMain" method="post" action="readData.php">
      <table width="600" border="1" id="tbExp">
        <tr>
          <td><div align="center">No </div></td>
          <td><div align="center">CustomerID </div></td>
          <td><div align="center">Name </div></td>
          <td><div align="center">Email </div></td>
          <td><div align="center">Country Code </div></td>
          <td><div align="center">Budget </div></td>
          <td><div align="center">Used </div></td>
          <td><div align="center">Popup </div></td>
          <td><div align="center">Del </div></td>
        </tr>
      </table>
      <input type="hidden" name="hdnMaxLine" value="0">
      <input name="btnAdd" type="button" id="btnAdd" value="+" onClick="CreateNewRow();">
      <input name="btnDel" type="button" id="btnDel" value="-" onClick="RemoveRow();">
      <input type="submit" name="btnSubmit" value="Submit">
    </form>
  </body>
</html>



ประวัติการแก้ไข
2016-02-03 01:41:07
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-02-03 01:40:11 By : progamer2000
 


 

No. 4



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



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


ขอบคุณครับ แต่มันยังมีปัญหาอยู่ตรง

สมมุติ ผมเพิ่มมา 4 row ใส่ข้อมูลทุก row แล้ว ที่นี้ ผมลบ row ที่ 2 ข้อมูลที่ ได้รับออกมา จะมีแค่ row 1 แค่นั้น row 3 , 4 ไม่มีข้อมูลมาครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-02-03 16:01:22 By : makdonal
 

   

ค้นหาข้อมูล


   
 

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