,我要做的就是点击“+”的时候触发一次事件,但是在别的"+"号那里可以用,不懂我的问题,可以在回复中说
function onclickBusiness(id){
if(id){
var xmlhttp=create();
xmlhttp.open("post","servlet/AjaxService");
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
var doc=xmlhttp.responseXML.documentElement;
var rows = doc.getElementsByTagName("row");
var div = document.createElement("div");
div.setAttribute("style","margin-left:140px;font-size:12px;");
var imgid=$(id);//得到在那里在实现一个层
for(var i = 0;i<rows.length;i++){
var r = rows[i];//得到行
var i1=r.childNodes[0].firstChild.nodeValue;//得到编号
var i2=r.childNodes[1].firstChild.nodeValue;//得到名称
var i3=r.childNodes[2].firstChild.nodeValue;//得到父编号
var p=document.createElement("p");
var input =document.createElement("input");
input.value=i2;
input.name="checks";
p.setAttribute("style","margin-top:3px;");
input.type="checkbox";
p.innerHTML=i2;
div.appendChild(p);
p.appendChild(input);
$(id).style.display="block";
}
alert(i1);
imgid.appendChild(div);
}else{
alert("错误:"+xmlhttp.status);
};
};
};
xmlhttp.send("m=selectBusiness&&id="+id);
}
}
只是我的代码
function onclickBusiness(id){
if(id){
var xmlhttp=create();
xmlhttp.open("post","servlet/AjaxService");
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
var doc=xmlhttp.responseXML.documentElement;
var rows = doc.getElementsByTagName("row");
var div = document.createElement("div");
div.setAttribute("style","margin-left:140px;font-size:12px;");
var imgid=$(id);//得到在那里在实现一个层
for(var i = 0;i<rows.length;i++){
var r = rows[i];//得到行
var i1=r.childNodes[0].firstChild.nodeValue;//得到编号
var i2=r.childNodes[1].firstChild.nodeValue;//得到名称
var i3=r.childNodes[2].firstChild.nodeValue;//得到父编号
var p=document.createElement("p");
var input =document.createElement("input");
input.value=i2;
input.name="checks";
p.setAttribute("style","margin-top:3px;");
input.type="checkbox";
p.innerHTML=i2;
div.appendChild(p);
p.appendChild(input);
$(id).style.display="block";
}
alert(i1);
imgid.appendChild(div);
}else{
alert("错误:"+xmlhttp.status);
};
};
};
xmlhttp.send("m=selectBusiness&&id="+id);
}
}
只是我的代码
解决方案 »
- js调用flash中的方法
- 怎么样能够使得JS操作数据库中记录 急!
- 请专家指点迷津,如何设置文本框只能输整数,能带+-号,首位数不能是0的JS完整代码效果,谢谢 。
- 杭州高速发展中的互联网公司诚聘.net开发工程师、技术经理!!!有意者加QQ:38908802
- 跪求!请问如何将完整网页转换文本网页?
- 折腾好多天了:想做类似 http://bt3.btchina.net 中的title效果???
- 从下拉菜单选择后把对应的多个值分别填充到多个文本框中
- 高分求教:怎么实现当鼠标移动到网页中一幅按比例缩小的图片上后即可显示出全尺寸的图片,或点击图片后弹出简洁的显示全尺寸图片的页面
- 为什么这段代码不可以在IE5.0下招行,请指正。。
- 如何将隐藏的表格恢复显示?
- 使用 Jquery 解析Web Service XML 文件,求高手指点!!!
- JS能不能获取给定连接里的所有class为nav的innerHTML属性值呢?
function onclickBusiness(id){
if(id){
var xmlhttp=create();
xmlhttp.open("post","servlet/AjaxService");
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
var doc=xmlhttp.responseXML.documentElement;
var rows = doc.getElementsByTagName("row");
var div = document.createElement("div");
div.setAttribute("style","margin-left:140px;font-size:12px;");
var imgid=$(id);//得到在那里在实现一个层
for(var i = 0;i<rows.length;i++){
var r = rows[i];//得到行
var i1=r.childNodes[0].firstChild.nodeValue;//得到编号
var i2=r.childNodes[1].firstChild.nodeValue;//得到名称
var i3=r.childNodes[2].firstChild.nodeValue;//得到父编号
var p=document.createElement("p");
var input =document.createElement("input");
input.value=i2;
input.name="checks";
p.setAttribute("style","margin-top:3px;");
input.type="checkbox";
p.innerHTML=i2;
div.appendChild(p);
p.appendChild(input);
$(id).style.display="block";
}
alert(i1);
imgid.appendChild(div);
}else{
alert("错误:"+xmlhttp.status);
};
};
};
xmlhttp.send("m=selectBusiness&&id="+id);}}能不能把代码整理一下
if (id) {
var imgid = $(id); //得到在那里在实现一个层//////////获取容器的地方钓上来
if (imgid.innerHTML != '') return////已经执行过ajax有内容,直接返回
var xmlhttp = create();
xmlhttp.open("post", "servlet/AjaxService");
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
var doc = xmlhttp.responseXML.documentElement;
var rows = doc.getElementsByTagName("row");
var div = document.createElement("div");
div.setAttribute("style", "margin-left:140px;font-size:12px;");
//var imgid = $(id); //得到在那里在实现一个层//////
for (var i = 0; i < rows.length; i++) {
var r = rows[i]; //得到行
var i1 = r.childNodes[0].firstChild.nodeValue; //得到编号
var i2 = r.childNodes[1].firstChild.nodeValue; //得到名称
var i3 = r.childNodes[2].firstChild.nodeValue; //得到父编号
var p = document.createElement("p");
var input = document.createElement("input");
input.value = i2;
input.name = "checks";
p.setAttribute("style", "margin-top:3px;");
input.type = "checkbox";
p.innerHTML = i2;
div.appendChild(p);
p.appendChild(input);
$(id).style.display = "block";
}
alert(i1);
imgid.appendChild(div);
} else {
alert("错误:" + xmlhttp.status);
};
};
};
xmlhttp.send("m=selectBusiness&&id=" + id); }}
......//
obj.onclick=null;
}
给所有+元素对象号都写 xxx.onclick=function(){var id=this.id;onclickBusiness(id,this);}
ok了