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 ที่เป็นรหัสสาขา แล้วไป select ค่าจาก database มาแสดงเป็น listbox ต้องแก้ไขตรงไหนคะ



 

สอบถามเรื่องการอ่านค่าจาก Textbox ที่เป็นรหัสสาขา แล้วไป select ค่าจาก database มาแสดงเป็น listbox ต้องแก้ไขตรงไหนคะ

 



Topic : 106805



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



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




สอบถามเรื่องการอ่านค่าจาก Textbox ที่เป็นรหัสสาขา แล้วไป select ค่าจาก database มาแสดงเป็น listbox ต้องแก้ไขตรงไหนคะ พอดีมีฟอร์มแบบนี้นะคะ ไปค้นกระทู้เก่า ๆ มาดัดแปลง แล้วหนูมี Code แบบนี้คะ หนูอยากรบกวนให้พี่ ๆ แนะนำตรง create selection นะคะ
<?php
include "Connect.php";

?>
<script language="javascript">
function CreateSelectOption(ele)
{
var objSelect = document.frmMain.Branchcode.value;
var sql = "SELECT Branch FROM Branch WHERE Branch='"+objSelect+"'";
var Item = new Option("", "");
objSelect.options[objSelect.length] = Item;
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
var Item = new Option("<?=$objResult["Branch"];?>", "<?=$objResult["Branch"];?>");
objSelect.options[objSelect.length] = Item;
<?
}
?>
}
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 1 ***//
newCell = newRow.insertCell(0);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column1_"+intLine+"\" ID=\"Column1_"+intLine+"\" VALUE=\"\"></center>";

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

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

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

//*** Column 5 ***//
newCell = newRow.insertCell(4);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"Column5_"+intLine+"\" ID=\"Column5_"+intLine+"\"></SELECT></center>";

//*** Create Option ***//
CreateSelectOption("Column5_"+intLine)

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;
}
}
</script>
<body>
<form name="frmMain" method="post">
<table width="50%" border="0" align="left">
<tr>
<td width="11%"><b>รหัสสาขา</b></td>
<td width="16%"><input name="Branchcode" type="text" id="Branchcode" size ="10" />
<input type="button" name="btnPopup" value="Search" ></td>
<td width="11%"><b>ชื่อ</b></td>
<td width="23%"><input name="Name" type="text" id="Name" />
<td width="9%"><b>นามสกุล</b></td>
<td width="13%"><input name="lastname" type="text" id="lastname" size ="10" />
</tr>
</table>


<table width="50%" border="1" id="tbExp">
<tr>
<td><div align="center">ลำดับที่</div></td>
<td><div align="center">รายการ </div></td>
<td><div align="center">ชื่อผู้สั่ง</div></td>
<td><div align="center">นามสกุล</div></td>
<td><div align="center">สาขา</div></td>
</tr>
</table>

<input type="hidden" name="hdnMaxLine" value="1">
<input name="btnAdd" type="button" id="btnAdd" value="+" onClick="CreateNewRow();">
<input name="btnDel" type="button" id="btnDel" value="-" onClick="RemoveRow();">
</form>
</body>
</html>



Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-03-12 08:09:48 By : pinkie View : 580 Reply : 5
 

 

No. 1



โพสกระทู้ ( 5,105 )
บทความ ( 4 )

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

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


เอา Code ใส่แท็ก PHP Code หน่อยครับ จะได้อ่านง่าย ๆ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-12 08:51:40 By : apisitp
 


 

No. 2



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



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


คะ ขอโทษคะ ยังใหม่อยู่คะ
Code (PHP)
<?php
include "Connect.php";

?>
<script language="javascript">
function CreateSelectOption(ele)
{
var objSelect = document.frmMain.Branchcode.value;
var sql = "SELECT Branch FROM Branch WHERE Branch='"+objSelect+"'";
var Item = new Option("", ""); 
objSelect.options[objSelect.length] = Item;
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
var Item = new Option("<?=$objResult["Branch"];?>", "<?=$objResult["Branch"];?>"); 
objSelect.options[objSelect.length] = Item;
<?
}
?>
}
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 1 ***//
newCell = newRow.insertCell(0);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column1_"+intLine+"\" ID=\"Column1_"+intLine+"\" VALUE=\"\"></center>";

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

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

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

//*** Column 5 ***//
newCell = newRow.insertCell(4);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"Column5_"+intLine+"\" ID=\"Column5_"+intLine+"\"></SELECT></center>";

//*** Create Option ***//
CreateSelectOption("Column5_"+intLine)

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;
} 
} 
</script>
<body>
<form name="frmMain" method="post">
<table width="50%" border="0" align="left">
<tr>
<td width="11%"><b>รหัสสาขา</b></td>
<td width="16%"><input name="Branchcode" type="text" id="Branchcode" size ="10" />
<input type="button" name="btnPopup" value="Search" ></td>
<td width="11%"><b>ชื่อ</b></td>
<td width="23%"><input name="Name" type="text" id="Name" />
<td width="9%"><b>นามสกุล</b></td>
<td width="13%"><input name="lastname" type="text" id="lastname" size ="10" />
</tr>
</table>


<table width="50%" border="1" id="tbExp">
<tr>
<td><div align="center">ลำดับที่</div></td>
<td><div align="center">รายการ </div></td>
<td><div align="center">ชื่อผู้สั่ง</div></td>
<td><div align="center">นามสกุล</div></td>
<td><div align="center">สาขา</div></td>
</tr>
</table>

<input type="hidden" name="hdnMaxLine" value="1">
<input name="btnAdd" type="button" id="btnAdd" value="+" onClick="CreateNewRow();">
<input name="btnDel" type="button" id="btnDel" value="-" onClick="RemoveRow();">
</form>
</body>
</html>



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-12 09:15:40 By : pinkie
 

 

No. 3



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



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


ใครพอจะช่วยแนะนำหนูได้บ้างคะ มึนหมดแล้ว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-12 09:53:11 By : pinkie
 


 

No. 4



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



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

ค่าจาก listbox คงที่ตลอดหรือว่ามีการเปลี่ยนแปลงเรื่อยๆ ครับ?
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-12 10:10:12 By : itpcc
 


 

No. 5



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



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


เปลี่ยนแปลงตลอดตาม รหัสสาขาคะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-12 11:36:32 By : pinkie
 

   

ค้นหาข้อมูล


   
 

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