Click here to Skip to main content
15,887,027 members
Home / Discussions / Web Development
   

Web Development

 
QuestionDialog auto-resize Pin
awedaonline27-Sep-12 8:25
awedaonline27-Sep-12 8:25 
AnswerRe: Dialog auto-resize Pin
Rockstar_7-Oct-12 21:01
professionalRockstar_7-Oct-12 21:01 
GeneralRe: Dialog auto-resize Pin
awedaonline12-Oct-12 1:12
awedaonline12-Oct-12 1:12 
QuestionMultilingual webpage Pin
Akash Patel25-Sep-12 6:27
Akash Patel25-Sep-12 6:27 
AnswerRe: Multilingual webpage Pin
Andrei Straut25-Sep-12 6:58
Andrei Straut25-Sep-12 6:58 
AnswerRe: Multilingual webpage Pin
Mighty Raju27-Sep-12 2:55
Mighty Raju27-Sep-12 2:55 
QuestionModifying accept header with IE9 and above Pin
Rajesh R Subramanian25-Sep-12 0:41
professionalRajesh R Subramanian25-Sep-12 0:41 
Questionvariable element id Pin
safa223-Sep-12 20:29
safa223-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
PHP
$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
XML
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
PHP
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
C#
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 Pin
Andrei Straut24-Sep-12 20:25
Andrei Straut24-Sep-12 20:25 
GeneralRe: variable element id Pin
safa226-Sep-12 4:35
safa226-Sep-12 4:35 
GeneralRe: variable element id Pin
Andrei Straut26-Sep-12 6:12
Andrei Straut26-Sep-12 6:12 
AnswerRe: variable element id Pin
Sebastiaan Meijerink30-Oct-12 4:08
professionalSebastiaan Meijerink30-Oct-12 4:08 
QuestionGet webcam capture Pin
Killzone DeathMan21-Sep-12 1:16
Killzone DeathMan21-Sep-12 1:16 
AnswerRe: Get webcam capture Pin
Joan M22-Sep-12 1:31
professionalJoan M22-Sep-12 1:31 
GeneralRe: Get webcam capture Pin
Killzone DeathMan22-Sep-12 11:10
Killzone DeathMan22-Sep-12 11:10 
QuestionHUGE Web Service Performance Issue Pin
Jammer21-Sep-12 0:53
Jammer21-Sep-12 0:53 
AnswerRe: HUGE Web Service Performance Issue Pin
jkirkerx21-Sep-12 11:04
professionaljkirkerx21-Sep-12 11:04 
GeneralRe: HUGE Web Service Performance Issue Pin
Mohibur Rashid22-Sep-12 3:00
professionalMohibur Rashid22-Sep-12 3:00 
GeneralRe: HUGE Web Service Performance Issue Pin
jkirkerx22-Sep-12 8:35
professionaljkirkerx22-Sep-12 8:35 
GeneralRe: HUGE Web Service Performance Issue Pin
manak chand22-Oct-12 0:24
manak chand22-Oct-12 0:24 
SuggestionStore the history of links the user visits of any browser Pin
Rockstar_19-Sep-12 18:21
professionalRockstar_19-Sep-12 18:21 
GeneralRe: Store the history of links the user visits of any browser Pin
Andrei Straut19-Sep-12 21:09
Andrei Straut19-Sep-12 21:09 
GeneralRe: Store the history of links the user visits of any browser Pin
Zamshed Farhan12-Jan-13 15:31
Zamshed Farhan12-Jan-13 15:31 
Questionsocket read on a keep alive request waits until connection timeout Pin
Jayapal Chandran17-Sep-12 4:50
Jayapal Chandran17-Sep-12 4:50 
QuestionPHP Pin
dashing_z14-Sep-12 14:23
dashing_z14-Sep-12 14:23 

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

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