0

This is the code that not getting the result

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Nice select</title>
<script Language="JavaScript">
function checkData()
    {
    
    var myTest  = me.D1.value;
     //alert(myTest);
	 
	 var req = new Request.JSON({
        url: 'dbselect.php',
        method: 'post',
        data: 'brand=' + encodeURIComponent(myTest)
    });
	 req.addEvent('success', function(response) {
				
			
			var ts = new String(response);
			document.me.inter.value = ts;

      
    });
    req.send();
	 
	 
     }
</script>

</head>

<body>
<form method="POST" name="me" id="me">
    <select size="1" name="D1"  onChange="checkData()">
    <option value="99">Default</option>    
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    </select>
    
    <input name="inter" id="inter"  type="text" >
</form>
</body>
</html>

This is the "dbselect.php" this is working well

<?php
include("../init/db.php");
$id=$_POST['brand'];
$sql="SELECT * FROM tea_type
WHERE id = '$id' ";
$data = mysql_query($sql);
while($info = mysql_fetch_array($data)){
	$model = $info['product'];

}
echo json_encode($model);
?>
2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by hielo
0

...var req = new Request.JSON where did you define the Request object? It looks like you forgot to "include/import/ling to" a javascript file!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.