我需要在使用 jquery 单击行图像时在表中添加新表
表格1
+-------------------------------+
|id name place view |
+-------------------------------+
|1 arun abc image1|
|2 jinu def image2|
+-------------------------------+
单击“image1”时,我想在单击的行下方显示新表
期望的输出
+----------------------------------+
|id name place view |
|----------------------------------|
|1 arun abc image1|
| |
|+--------------------------------+|
||name fname last name age ||
||--------------------------------||
||arun arun babu 10 ||
|+--------------------------------+|
| |
|2 jinu def image2 |
+----------------------------------+
我试过这个但没有输出
function validation_over() {
$.ajax({
type:'post',
url: '<?php echo site_url('page_control/main_report'); ?>', //Posting all data
data:{
//fn:"table"
district:$('#cbo_district').val(),
rpt_nm:$('#cbo_rpt_typ').val(),
type:$('#rpt_type').val(),
frm_date:$('#frm_date').val(),
to_date:$('#to_date').val(),
},
dataType: 'json', //Data format
success: function(data) { //Receiving data
if(data.status=="nodata") {
alert("No data found");
}
var sales_tot=0;
var movie_tot=0;
var still_tot=0;
result="<table border='0' name='main_rpt_tbl1' id='main_rpt_tbl' class='table'>";
result+="<CAPTION><EM>Report:"+data.rpt_nm+"</EM></CAPTION>";
if(data.typ=="d") {
result+="<tr><td rowspan='2' colspan='3' style='color:green;'>District:"+data.rate[0].DistrictName+"   Date:"+data.frm_dat+"</td></tr><tr></tr>";
} else {
result+="<tr><td rowspan='2' colspan='3' style='color:green;'>District:"+data.rate[0].DistrictName+"   Date:"+data.frm_dat+"-"+data.to_dat+"</td></tr><tr></tr>";
}
result+="<tr><th rowspan='2'>Centre Name</th>";
if(data.rpt_nm=="Sales Information") {
result+="<th rowspan='2'>Total Sales</th><th rowspan='2'>View</th></tr><tr></tr>";
} else {
result+="<th rowspan='2'>Total Visitors</th><th rowspan='2'>View</th></tr><tr></tr>";
}
for(var i=0;i<data.rate.length;i++) {
CentreID=data.rate[i].CentreID;
CentreName=data.rate[i].CentreName;
adult_tot=data.rate[i].adult_tot;
child_tot=data.rate[i].child_tot;
foreign_tot=data.rate[i].foreign_tot;
if(data.rpt_nm=="Sales Information") {
movie_tot=data.rate[i].movie_tot;
still_tot=data.rate[i].still_tot;
}
tot=parseInt(adult_tot)+parseInt(child_tot)+parseInt(foreign_tot)+parseInt(movie_tot)+parseInt(still_tot);
//result+="<tr onClick=update(this);centre("+ DistrictCd + ",'tbl')>";
result+="<tr>";
result+="<td>"+CentreName+"</td>";
result+="<td>"+tot+"</td>";
result+="<td onClick='onClick=get_data("+CentreID+");' id='q'><img src='<?php echo base_url(); ?>styles/images/delete.png' title='Delete' width='20' height='20'></td>";
result+="<td style='display:none'>"+CentreID+"</td>";
result+="</tr>";
}
result+="</table>";
$('#main_rpt_tbl').html(result);
}
});
}
function get_data(id) {
var tRow = "<tr><table><tr><td>...</td>...</tr>...</table></tr>";//code for your table
$(this).parent('tr').after(tRow );
}