?asp.net前台调用后台方法以及后台调用前台JS.
前台:
functionmodifyData()
{
varresult=0;
varstring_tmp='';
varstring_index='';
//請先選擇一筆數據
varGV_Table=document.getElementById('GV_Emp');
for(vari=0;i {
vartmp_col=GV_Table.rows[i].cells[0].children;
for(varz=0;z {
if(tmp_col[z].type=="checkbox"&;&;tmp_col[z].checked)
{
result++;
string_index=i;
string_tmp=tmp_col[z].id;
}
}
}
if(result==0)
{
alert("請先選擇一行數據!");
returnfalse;
}
if(result>1)
{
alert("只能選擇一行數據!");
returnfalse;
}
document.getElementById("Hidden1").value=string_tmp;
document.getElementById("Hidden2").value=string_index;
document.getElementById("Button1").click();//前台调用后台方法
}
functionsetData(){
varstring_tmp=document.getElementById("Hidden1").value;
document.getElementById('txt_flag').value='modify';
document.getElementById("d_message").style.display="block";
varrow_tmp=document.getElementById(string_tmp).parentNode.parentNode;
document.getElementById("txt_empId").value=row_tmp.getElementsByTagName("td")[2].innerText;
document.getElementById("txt_dept").value=row_tmp.getElementsByTagName("td")[5].innerText;
document.getElementById("txt_empName").value=row_tmp.getElementsByTagName("td")[3].innerText;
document.getElementById('txt_empId').readOnly=true;
varplant_sel=document.getElementById("DDL_ManageCode");
varplant_name=row_tmp.getElementsByTagName("td")[8].innerText;
for(i=0;i {
if(plant_name==plant_sel.options[i].text)//if(plant_name==plant_sel.options[i].value)
{
plant_sel.options[i].selected=true;
break;
}
}
plant_sel=document.getElementById("DDL_group");
plant_name=row_tmp.getElementsByTagName("td")[6].innerText;
for(i=0;i {
if(plant_name==plant_sel.options[i].value)
{
plant_sel.options[i].selected=true;
break;
}
}
}