I want to show select boxes and check boxes(as checked), from an AJAX response. I am passing a string and then exploding to get array results for select boxes. How can I do this with checkboxes too.
in escalation_ajax,
echo '<option value="'.$id.'">'.$reporting_head.'</option>'.",".'<option value="'.$des_id.'">'.$des_name.'</option>'.",".'<option value="'.$designation_email.'">'.$rep_head.'</option>' ;
and escalation.php
<b>CC To:</b><br>
<?php
$sqlrep = mysql_query("SELECT id, reporting_head FROM tbl where level > 0 GROUP BY reporting_head");
while ($rows1 = mysql_fetch_assoc($sqlrep)){
$rep_id2 = $rows1['id'];
$repname2 = $rows1['reporting_head'] ;
echo "<input type='checkbox' name='cc2' value='".$rep_id2."'> ". $repname2 ."<br>";
}
?>
<script type="text/javascript">
$(document).ready(function()
{
$("#desig").change(function()
{
var designationname2 = $(this).find("option:selected").text()
var id=$(this).val();
var dataString = { 'id': id , 'designationname2': designationname2};
$.ajax
({
type: "POST",
url: "escalation_ajax.php",
data: dataString,
cache: false,
success: function(html)
{
var data = html.split(",");
$("#rephead").html("");
$('#rephead').append(data[0]);
$("#rephead1").html("");
$('#rephead1').append(data[0]);
$("#rephead2").html("");
$('#rephead2').append(data[0]);
$('#dd').html("");
$('#dd').append(data[1]);
$('#rephead3').html("");
$('#rephead3').append(data[2]);
}
});
});
});
</script>
Aucun commentaire:
Enregistrer un commentaire