Jump to content

Recommended Posts

I have the following code for my dropbox;

 

<select name="Symptom" id="Symptomid"  onchange="LSC(this.value)"> 

 

Its options are;

 

  <option value="<?php echo $row_RsSymptom['name']?>"><?php echo $row_RsSymptom['name']?></option>

 

i have the script ;

 

<script>
function LSC(str) {
     if (str == "") {
        document.getElementById("txtHint").innerHTML = "";
        return;
    } else { 
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {
            // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET","LoadSymptomDetails.php?q="+str,true);
        xmlhttp.send();
    }
}
</script>
 
 
The LoadSymptomDetails.php
 
has the following lines;
 
$sql1 = mysql_query("SELECT name,description , comments
FROM symptoms WHERE symptoms.name ='".$q."'") or die(mysql_error());
 
 
The q is not being picked. If i remove the where statement it runs and displays the table.
 
 
Kindly assist.
 
Azhar
 

 

 

Link to comment
https://forums.phpfreaks.com/topic/299301-on-select-value-not-being-passed-to-php/
Share on other sites

  • 3 weeks later...

are you assigning a value to $q?

when passing values through form input (either by ajax or normal form submission) the value is normally passed to either the $_GET or $_POST superglobals.  To get the value out of that you would access it like any other associative array:

 

$q = $_GET['q'];
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.