function showRole(str,x) { if (str=="") { document.getElementById("txtHintrole"+x+"").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHintrole"+x+"").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","http://localhost/tes/index.php/form/role/"+str,true); xmlhttp.send(); }
function showUser(str,x) { if (str=="") { document.getElementById("txtHint"+x+"").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint"+x+"").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","http://localhost/tes/index.php/form/hint/"+str,true); xmlhttp.send(); }
我可以将这个2功能加入到1中 因为我需要他们两个来显示数据 我不知道如何用这个
设置2个功能newcell.childNodes [0] .setAttribute( “平变化”, “showUser(THIS.VALUE,” + XX + “);”);
答案 0 :(得分:3)
当然,只需创建一个包装函数:
var showBoth = function(str, x) {
showRole(str, x);
showUser(str, x);
};