I am printing checkbox's value on combobox value using AJAX, but showing undefined.
First time it ok, but When checkbox is clicked then value is set to be off, showing undefined.

Here is the code.
Checkbox

<input type="checkbox" name="course_inactive" value="off" id="course_inactive" onclick="check(this.value); value2(this.value)">

Combobox
<div style="float:right; height: 26px; padding-top:2px;" id="div_courses">
<select id="course" name="course" style="width:125px" onchange="selectBatch(this.value); showCourseBatch(this.value, document.getElementById('batch').value, document.getElementById('orderby').value, document.getElementById('sortby').value, document.getElementById('course_inactive').value)">
<?php
foreach ($options_courses as $index => $value)
{
echo ' <option value="' . $index . '"';
if ($index == $course_to_preselect)
{
echo ' selected ';
}
echo '>' . $value . '</option>';
}
?>
</select>
</div>

AJAX Function
function showCourseBatch(str,str1,str2,str3,str4)
{
//alert(str2+' '+str3 );
alert(str4);
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="SelReceiptByCourse.php";
url=url+"?c="+str;
url=url+"&b="+str1;
url=url+"&orderby="+str2;
url=url+"&sortby="+str3;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

Use this.checked.

Be a part of the DaniWeb community

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