|
|
|
ใส่ onchange ตรงไหน เปลี่ยนรูปแบบใหม่ ครับ เป็น onchange |
|
|
|
|
|
|
|
เปลี่ยนรูปแบบใหม่ ครับ เป็น onchange
Code (PHP)
<?php
include 'connect.php';
$connectionInfo = array("Database"=>$dbName, "UID"=>$userName, "PWD"=>$userPassword, "MultipleActiveResultSets"=>true);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
?>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<script language="javascript">
/*function fncAlert()
{
var keep=document.getElementById("game").value;
var voteable = (keep != "a") ? "not a":"yes a";
alert(voteable + " to vote.");
}*/
</script>
<?php
//error_reporting(0);
$item=$_POST["item"];
//echo $item;
?>
<form name="form" method="post" id="form1" name="form1" action="add8.php">
<table border="1">
<tr>
<td><input id="item" name="item" list="itemlist" style="width: 80px" value="<?php error_reporting(0); echo $_POST['item'];?>">
<datalist id="itemlist" >
<?php
$itsql="SELECT top 10000 * FROM ITEM";
$itquery=sqlsrv_query($conn, $itsql);
while($result = sqlsrv_fetch_array($itquery))
{?>
<option><?php echo $result["ITEM"];?></option>
<?php }
?>
</datalist></td>
<?php $itsql="SELECT * FROM ITEM where item='".$item."'";
$itquery=sqlsrv_query($conn, $itsql);
$result = sqlsrv_fetch_array($itquery); ?>
<td><input type="text" name="textfield" id="numtxt" style="width:400px" value="<?php error_reporting(0);
$arr=$result["DESCRIPTION"];
echo $arr; ?> "> </td>
<td><input type="text" name="mrpc" id="numtxt" style="width:400px" value="<?php error_reporting(0);
$arr=$result["MRPC"];
echo $arr; ?> " </td>
<!--<td><input type="text" name="text<?=$i?>"></td>-->
<!--<td><input id="item" name="item" list="itemlist" style="width: 80px" onKeyUp="document.form.textfield.value='
/*$itsql="SELECT * FROM ITEM where item='".$item."'";
$itquery=sqlsrv_query($conn, $itsql);
$result = sqlsrv_fetch_array($itquery);
$arr=$result["DESCRIPTION"];
echo $arr; */
?>';">
<datalist id="itemlist" >
/*$itsql="SELECT top 100 * FROM ITEM";
$itquery=sqlsrv_query($conn, $itsql);
while($result = sqlsrv_fetch_array($itquery))
{
?>
<option>echo $result["ITEM"];?></option>
}*/
</datalist></td>
<td><input type="text" name="item" onKeyUp="document.form.textfield.value='<?php $itsql="SELECT * FROM ITEM where item='".$_POST['item']."'";
$itquery=sqlsrv_query($conn, $itsql);
$result = sqlsrv_fetch_array($itquery);
$arr=$result["DESCRIPTION"];
echo $_POST['item'];
?>';"></td>
<td><input type="text" name="textfield" id="numtxt" style="width:400px"></td>-->
</tr>
</table>
<button type="submit" value="Submit">Refresh</button>
</form>
Tag : PHP, Ms SQL Server 2005
|
|
|
|
|
|
Date :
2016-07-13 14:40:00 |
By :
pissanu8970 |
View :
1078 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
การใช้งานมันขึ้นอยู่กับเหตุการณ์ และรูปแบบการใช้ form ครับ
onchang ส่วนใหญ่ใช้กับ select option
onclick ส่วนใหญ่ใช้กับ button
onkeyup onkeypress ส่วนใหญ่ใช้กับ input ครับ
เลือกใช้ให้ถูกและถ้าลงโค๊ดรบกวนด codetag php ด้วยนะครับ
<?php
include 'connect.php';
$connectionInfo = array("Database"=>$dbName, "UID"=>$userName, "PWD"=>$userPassword, "MultipleActiveResultSets"=>true);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
?>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<script language="javascript">
/*function fncAlert()
{
var keep=document.getElementById("game").value;
var voteable = (keep != "a") ? "not a":"yes a";
alert(voteable + " to vote.");
}*/
</script>
<?php
//error_reporting(0);
$item=$_POST["item"];
//echo $item;
?>
<form name="form" method="post" id="form1" name="form1" action="add8.php">
<table border="1">
<tr>
<td><input id="item" name="item" list="itemlist" style="width: 80px" value="<?php error_reporting(0); echo $_POST['item'];?>">
<datalist id="itemlist" >
<?php
$itsql="SELECT top 10000 * FROM ITEM";
$itquery=sqlsrv_query($conn, $itsql);
while($result = sqlsrv_fetch_array($itquery))
{?>
<option><?php echo $result["ITEM"];?></option>
<?php }
?>
</datalist></td>
<?php $itsql="SELECT * FROM ITEM where item='".$item."'";
$itquery=sqlsrv_query($conn, $itsql);
$result = sqlsrv_fetch_array($itquery); ?>
<td><input type="text" name="textfield" id="numtxt" style="width:400px" value="<?php error_reporting(0);
$arr=$result["DESCRIPTION"];
echo $arr; ?> "> </td>
<td><input type="text" name="mrpc" id="numtxt" style="width:400px" value="<?php error_reporting(0);
$arr=$result["MRPC"];
echo $arr; ?> " </td>
<!--<td><input type="text" name="text<?=$i?>"></td>-->
<!--<td><input id="item" name="item" list="itemlist" style="width: 80px" onKeyUp="document.form.textfield.value='
/*$itsql="SELECT * FROM ITEM where item='".$item."'";
$itquery=sqlsrv_query($conn, $itsql);
$result = sqlsrv_fetch_array($itquery);
$arr=$result["DESCRIPTION"];
echo $arr; */
?>';">
<datalist id="itemlist" >
/*$itsql="SELECT top 100 * FROM ITEM";
$itquery=sqlsrv_query($conn, $itsql);
while($result = sqlsrv_fetch_array($itquery))
{
?>
<option>echo $result["ITEM"];?></option>
}*/
</datalist></td>
<td><input type="text" name="item" onKeyUp="document.form.textfield.value='<?php $itsql="SELECT * FROM ITEM where item='".$_POST['item']."'";
$itquery=sqlsrv_query($conn, $itsql);
$result = sqlsrv_fetch_array($itquery);
$arr=$result["DESCRIPTION"];
echo $_POST['item'];
?>';"></td>
<td><input type="text" name="textfield" id="numtxt" style="width:400px"></td>-->
</tr>
</table>
<button type="submit" value="Submit">Refresh</button>
</form>
|
|
|
|
|
Date :
2016-07-13 15:32:57 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ต้องขอโทษทีครับที่ไม่ได้ทำ codetag php
ไม่ได้อ่ะครับ อเลือกแล้วไม่ Auto นะครับ
|
|
|
|
|
Date :
2016-07-13 15:38:04 |
By :
pissanu8970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อยากจะเปลี่ยนตรงไหนครับ ให้มันไปดึงคำสั่งไหนมาครับ รบกวนโฟกัสจุดหน่อยครับ
|
|
|
|
|
Date :
2016-07-13 16:49:58 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<form name="form" method="post" id="form1" name="form1" action="add11.php">
<table border="1">
<tr>
<td><input id="item" name="item" list="itemlist" onkeyup="myFunction(this)" style="width: 80px" value="<?php error_reporting(0); echo $_POST['item'];?>">
<datalist id="itemlist" >
<?php
$itsql="SELECT top 10000 * FROM ITEM";
$itquery=sqlsrv_query($conn, $itsql);
while($result = sqlsrv_fetch_array($itquery))
{?>
<option><?php echo $result["ITEM"];?></option>
<?php }
?>
</datalist></td>
<?php $itsql="SELECT * FROM ITEM where item='".$item."'";
$itquery=sqlsrv_query($conn, $itsql);
$result = sqlsrv_fetch_array($itquery); ?>
<td><input type="text" name="textfield" id="numtxt" style="width:400px" value="<?php error_reporting(0);
$arr=$result["DESCRIPTION"];
echo $arr; ?> "> </td>
<td><input type="text" name="mrpc" id="numtxt" style="width:400px" value="<?php error_reporting(0);
$arr=$result["MRPC"];
echo $arr; ?> " </td>
|
|
|
|
|
Date :
2016-07-13 16:58:42 |
By :
pissanu8970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<input id="item" name="item" list="itemlist" onchange="myFunction(this)" style="width: 80px" value="<?php error_reporting(0); echo $_POST['item'];?>">
ละลานตา น่าดู -.-"
|
|
|
|
|
Date :
2016-07-13 17:02:39 |
By :
dudesaranyu |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|