Click here to Skip to main content
       

Web Development

 
QuestionDialog auto-resize Pinmemberawedaonline27-Sep-12 8:25 
AnswerRe: Dialog auto-resize PinmemberVijayChauhan1237-Oct-12 21:01 
GeneralRe: Dialog auto-resize Pinmemberawedaonline12-Oct-12 1:12 
QuestionMultilingual webpage PinmemberAkash Patel25-Sep-12 6:27 
AnswerRe: Multilingual webpage PinmemberAndrei Straut25-Sep-12 6:58 
AnswerRe: Multilingual webpage PinmemberMighty Raju27-Sep-12 2:55 
QuestionModifying accept header with IE9 and above [modified] PinmemberRajesh R Subramanian25-Sep-12 0:41 
Questionvariable element id Pinmembersafa223-Sep-12 20:29 
hello!
i'm newbie in ajax,php .i'm doing the following
1. connect to sql get hospitals name and display it
$con = mysql_connect("localhost","root","");
$address="nothing!";
$tel="nothing";
$desc="nothing";
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
    mysql_select_db("trial", $con);
    $q=mysql_query("select g_name from  govermental_hos");
 
no problem with that.
 
2. display as dl
echo "<dl>";
    while($row=mysql_fetch_array($q))
    {
    echo "<dt onclick=\"ajaxFunction()"\">";
    echo $row['g_name']."</dt>";
 
    }
    echo"</dl>";
 

 
no problem with it
3. i want to give each id (would be variable)
then i wonna make onclick event so php will get info about the name clicked
function hos_info($g_name)
{
$query= mysql_query("select g_address,g_tel ,g_description from govermental_hos where g_name like '".$g_name."'");
if($row=mysql_fetch_array($query))
{ $address=$row['g_address'];
$tel=$row['g_tel'];
$desc=$row['g_description'];
echo $address;
}
}
 
the problem is
1.how can i access the clicked item via the java script

the script is
function ajaxFunction(){
    var ajaxRequest;  // The variable that makes Ajax possible!

    try{
        // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        // Internet Explorer Browsers
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                // Something went wrong
                alert("Your browser broke!");
                return false;
            }
        }
    }
}
//-->
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
        // Get the data from the server's response
    }
    var g =  "<?php echo $row['g_name']; ?>";
 
    ajaxRequest.open("GET", "gov_fetch_data.php" + g, true);
ajaxRequest.send(null);
}
</script>

AnswerRe: variable element id PinmemberAndrei Straut24-Sep-12 20:25 
GeneralRe: variable element id Pinmembersafa226-Sep-12 4:35 
GeneralRe: variable element id PinmemberAndrei Straut26-Sep-12 6:12 
AnswerRe: variable element id PinmemberSebastiaan Meijerink30-Oct-12 4:08 
QuestionGet webcam capture PinmemberKillzone DeathMan21-Sep-12 1:16 
AnswerRe: Get webcam capture PinmemberJoan Murt22-Sep-12 1:31 
GeneralRe: Get webcam capture PinmemberKillzone DeathMan22-Sep-12 11:10 
AnswerMessage Automatically Removed Pinmembersarlishah19-Oct-12 22:00 
QuestionHUGE Web Service Performance Issue PinmemberJammer21-Sep-12 0:53 
AnswerRe: HUGE Web Service Performance Issue Pinmemberjkirkerx21-Sep-12 11:04 
GeneralRe: HUGE Web Service Performance Issue PinmemberMohibur Rashid22-Sep-12 3:00 
GeneralRe: HUGE Web Service Performance Issue Pinmemberjkirkerx22-Sep-12 8:35 
GeneralRe: HUGE Web Service Performance Issue Pinmembermanak chand22-Oct-12 0:24 
SuggestionStore the history of links the user visits of any browser PinmemberVijayChauhan12319-Sep-12 18:21 
GeneralRe: Store the history of links the user visits of any browser PinmemberAndrei Straut19-Sep-12 21:09 
GeneralRe: Store the history of links the user visits of any browser PinmemberS.M. Zamshed Farhan12-Jan-13 15:31 
Questionsocket read on a keep alive request waits until connection timeout PinmemberJayapal Chandran17-Sep-12 4:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.140905.1 | Last Updated 9 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid