1.UserBmmcGenerate .java
public class UserBmmcGenerate {
public UserBmmcGenerate()
{
}
public String getAllBM(int bmid)
{
String bmmc="";
try
{
//省略数据库获取数据
}catch(Exception e)
{
}finally
{
//省略关闭数据步骤
}
return bmmc;
}
}
2.前台页面:getbmmc.jsp
<head>
<script src="../dwr/interface/AllBMMCList.js"></script>
<script type="text/javascript" src='../dwr/engine.js'></script>
<script type="text/javascript" src='../dwr/util.js'></script>
<script language="javascript">
var current_html=null;
function getbmmc(bmid,htmlid)
{
current_html=htmlid;
AllBMMCList.getAllBM(createList2,bmid);
}
function createList2(data1)
{
document.getElementById(current_html).innerHTML="<span class=/"blue01/">"+data1+"</span>";
//alert(data1);
}
</script>
</head>
............................省略n个字.........................................................
<td id=<%=i%> onClick="getbmmc(<%=ygbm%>,<%=i%>)" >部门名称在此处改变</td>
............................省略n个字.........................................................
基本搞定,注意如果ID不是动态生成的,那个在上面document.getElementById(current_html).innerHTML="<span class=/"blue01/">"+data1+"</span>";
处可以直接写上 id.innerHTML="改变的数据";