ajax problem

ajax problem

veto611veto611 Posts: 3Questions: 0Answers: 0
edited August 2013 in General
iam using form to add new target to user
i need when he choose from menu without refresh page the information about this record show in text (chained select)
i'm using ajax but code have error i don't know it :(
code for part_a_new

`

Part A

body {
background-image: url(images/background.png);
}




function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}

return xmlhttp;
}

function getMake(id) {

var strURL="findmake.php?id="+id;
var req = getXMLHTTP();

if (req) {

req.onreadymakechange = function() {
if (req.readyMake == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('makediv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
function getMake(id) {
var strURL="findlast.php?id="+id;
var req = getXMLHTTP();

if (req) {

req.onreadymakechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('lastdiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}

}





Substation_name:

<?php
do {
?>
<?php echo $row_substation['station']?>
<?php
} while ($row_substation = mysql_fetch_assoc($substation));
$rows = mysql_num_rows($substation);
if($rows > 0) {
mysql_data_seek($substation, 0);
$row_substation = mysql_fetch_assoc($substation);
}
?>




Make:






Prev_MTC:





`
code for findmake.php
`
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Untitled Document



<?php $make=intval($_GET['id']);
$link = mysql_connect('localhost', 'root', ''); //changet the configuration in required
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('trsh');
$query="SELECT id,make FROM substations WHERE id ='$make'";
$result=mysql_query($query);

?>


<?php while($row=mysql_fetch_array($result)) { ?>
<?php echo $row['make']?>
<?php } ?>



`

code for findlast.php

`
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Untitled Document



<?php $last=intval($_GET['id']);
$link = mysql_connect('localhost', 'root', ''); //changet the configuration in required
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('trsh');
$query="SELECT id,last FROM substations WHERE id ='$last'";
$result=mysql_query($query);

?>


<?php while($row=mysql_fetch_array($result)) { ?>
<?php echo $row['last']?>
<?php } ?>




`
database
new:
id,station,make,last,foward,user,date
station:
id,station,make,last

we bring data fron station to but in new and complete information

plz help me

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Please see http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read
  • veto611veto611 Posts: 3Questions: 0Answers: 0
    i see but there is three pages how can i know where is the mistake??
  • veto611veto611 Posts: 3Questions: 0Answers: 0
    iam fix proplem with this code

    <?php echo $row_station['station']?>

    $("#selectstation").change(function (){
    var VALUESTATION = $("#selectstation").val();
    $("#makediv").load("findmake.php?id="+VALUESTATION);
    $("#lastdiv").load("findlast.php?id="+VALUESTATION);
    //alert(VALUESTATION);
    });


    but how can i get label not value ineed to get name not id can any one help me??
This discussion has been closed.