|
|
|
เลือกข้อมูลจาก drop down โชว์ได้ใน 2 textfield ผมทำได้แค่ textfield เดียวเอง ทำยังไงครับ รบกวนหน่อย |
|
|
|
|
|
|
|
Code (PHP)
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<script src="http://code.jquery.com/jquery-latest.js"> </script>
<script>
function record(Code95){
$.ajax({url:"test.php",
async:false,
cache:false,
global:false,
type:'GET',
data:'Code95='+Code95,
dataType:"html",
success: function(result){
$('#Desc').html(result);
}
});
}
function record1(Code95){
$.ajax({url:"test1.php",
async:false,
cache:false,
global:false,
type:'GET',
data:'Code95='+Code95,
dataType:"html",
success: function(result){
$('#textMajor').html(result);
}
});
}
</script>
<body>
<?
mysql_connect("localhost","root","root") or die(mysql_error());
mysql_select_db("Punch_list")
?>
<form name="frmMain" method="get" action="../Record_sample.php" target="iframe_target">
<iframe id="iframe_target" name="iframe_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
<p>
<div align="center">
<table width="928" border="1" >
<? echo "<caption> MS95 </caption>" ?>
<tr>
<td height="90"><div align="center"><span class="style1">Deficiency Code(MS95)</span></div></td>
<td><div align="center"><span class="style1">Description</span></div></td>
<td><div align="center"><span class="style2">Major/Minor</span></div></td>
<td><div align="center">
<p class="style1">Amount of Deficiency</p>
</div></td>
<td><div align="center"><span class="style1">Description yourself</span></div></td>
</tr>
<tr>
<td width="132" height="90"><label>
<select name="Code95" size="1" id="Code95" onChange="record($('#Code95').val())"; >
<option value="">- Choose -</option>
<?php //
$str = "SELECT* FROM MS95"; //เลือกตารางฐานข้อมูลที่จะแสดง
$strQUERY = mysql_query($str);
while($result=mysql_fetch_array($strQUERY))
{
if($_GET["Code95"] == $result["Code"])//เพื่อให้ แสดง $deficiency_code ที่ส่งค่ามาให้
{
$sel="selected";
}
else
{
$sel="";
}
?>
<option value="<?=$result["Code"];?>"<?=$sel;?>>
<?=$result["Code"];?>
</option>
<?
}
?>
</select>
</label></td>
<td width="203">
<label>
<textarea name="Desc" cols="30" rows="4" id="Desc" > </textarea>
</label>
<div align="left"></div>
</label></td>
<td width="111"><label>
<label>
<div align="center">
<textarea name="textMajor" cols="15" rows="4" id="textMajor"></textarea>
</div>
</label>
</label></td>
<td width="224"><div align="center">
<input name="Deficiency" type="text" id="Deficiency" size="10">
</div></td>
<td width="224"><div align="center">
<textarea name="textDescription" cols="30" rows="4" id="textDescription"></textarea>
</div></td>
</tr>
</table>
</div>
<div align="center">
<input type="submit" name="button" id="button" value="Enter" >
<label></label>
<label></label>
<input type="submit" name="button2" id="button2" value="Finish" onClick="window.location='example.php'" />
</div>
</label>
<label>
<div align="center">
<label></label>
</div>
</form>
<div align="center">
<p> </p>
<table width="252" border="0">
<tr>
<td width="112"><a href="../search.php">Show Result</a> <font size="3" face="MS Sans Serif, Tahoma, sans-serif"><a href="file:///C|/AppServ/www/Member/Change_Password.php"> </a></font></td>
<td width="130"><font size="3" face="MS Sans Serif, Tahoma, sans-serif"><a href="file:///C|/AppServ/www/Member/Change_Password.php">เปลี่ยนรหัสผ่าน</a><strong> </strong> </font></td>
</tr>
</table>
</div>
<p align="center"> </p>
<p align="center"> </p>
</body>
</html>
test (PHP)
<?
mysql_connect("localhost","root","root") or die(mysql_error());
mysql_select_db("Punch_list");
if($_GET["Code95"] != "")
{
$str = "SELECT * FROM MS95 WHERE Code = '".$_GET["Code95"]."' ";
mysql_query("SET NAMES utf8");
$strQUERY = mysql_query($str);
$result = mysql_fetch_array($strQUERY);
}
?>
<?=$result["Description"];?>
test1 (PHP)
<?
mysql_connect("localhost","root","root") or die(mysql_error());
mysql_select_db("Punch_list");
if($_GET["Code95"] != "")
{
$str1 = "SELECT * FROM MS95 WHERE Code = '".$_GET["Code95"]."' ";
mysql_query("SET NAMES utf8");
$strQUERY1 = mysql_query($str1);
$result = mysql_fetch_array($strQUERY1);
}
?>
<?=$result["Major_Minor"];?>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2013-06-02 00:11:00 |
By :
artsurasak |
View :
804 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|