I'm trying to create a webpage to help teacher determine CLO and PLO for exam questions
First user will type the keyword in text box and select the chapter CLO() function will start the AJAX the result should be a CLO Number in CLO column and PLO options in PLO column. it is my first time using AJAX so I'm not should what is wrong
this is my code

<! Doctype html>
    <script>function CLO() {
    var a=document.getElementById("keyword").value;
    var b=document.getElementById("chapter").value;
        if (a == ""&& b == "") {
            document.getElementById("CLO").innerHTML = "";
            document.getElementById("PLO").innerHTML = "";
        } 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("CLO").innerHTML = xmlhttp.responseText;
                    document.getElementById("PLO").innerHTML = xmlhttp.responseText;

    <body><form><table id="dataTable" >
    <tr><th>Q </th><th>Keyword</th><th>Chapter</th><th>CLO</th> <th>PLO</th><th> Marks</th></tr>
    <tr><td> 1</td><td> <input type="text" name="keyword[]" id="keyword" > </td> 
     <td> Chapter: <select name="chapter[]" id="chapter" onchange="CLO()"> <option value="" >  </option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>


    <td id="CLO"> gghjgh</td>  </td>
    <td><select name="PLO" id="PLO"> <option >  </option>
    <td> <input type="text" name="mark[]"> </td></tr>


PHP Page

<!DOCTYPE html>


$q1 = intval($_GET['q1']);
$q2 = intval($_GET['q2']);
$con = mysqli_connect("localhost","FYP","123","FYP");
if (!$con) {
    die('Could not connect: ' . mysqli_error($con));}

if ($q1=="Cite" || "Define "){
return $level=1;}
elseif ($q1==""){
    return $level=2;
$sql1="SELECT * FROM SYLL_INFO WHERE C_Chapter = '".$q2."' AND Syll_pLO LIKE  '%".$level."'";
$result1 = mysqli_query($con,$sql1);
while($row = mysqli_fetch_array($result)) { 
    echo "<td><option >". $row['Syll_PLO']. "</option></td>" ;
$sql2="SELECT * FROM SYLL_INFO WHERE C_Chapter = '".$q2."'";
$result2 = mysqli_query($con,$sql2);
while($row = mysqli_fetch_array($result)) { 
    echo "<td>". $row['Syll_CLO']."</td>" ;

Appreciate your help

Re: post 2 values to php using ajax and receive 2 values 80 80

When you construct the URL in AJAX code, you have to separate the query parameters by ampersand (&). That is, ql=a&q2=b

commented: it solve the php error I used to have but still no value received +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.