日期:2014-05-18  浏览次数:20674 次

关于ajax问题,寻求解决办法
/*分析返回的XML文档*/

function   complete()

{

if   (req.readyState   ==   4)

{  

if   (req.status   ==   200)

  {  

var   type   =   req.responseXML.getElementsByTagName( "content ");  

var   str=new   Array();
for(var   i=0;i <type.length;i++)

{

str[i]=(type[i].firstChild.data).split( "@@@ ");
var   kkk=str[i]
//////////////
}
}
以下是表单中的复选框
<html:form   action= "/usergg.do "   method= "post ">
<input   type= "checkbox "   name= "aaa1 "   id= "aaa1 "> <br>
<input   type= "checkbox "   name= "aaa2 "   id= "aaa2 "> <br>
<input   type= "checkbox "   name= "aaa3 "   id= "aaa3 "> <br>
<input   type= "checkbox "   name= "aaa4 "   id= "aaa4 "> <br>
<input   type= "checkbox "   name= "aaa5 "   id= "aaa5 "> <br>
<input   type= "checkbox "   name= "aaa6 "   id= "aaa6 "> <br>
<input   type= "checkbox "   name= "aaa7 "   id= "aaa7 "> <br>
<input   type= "checkbox "   name= "aaa8 "   id= "aaa8 "> <br>
<input   type= "checkbox "   name= "aaa9 "   id= "aaa9 "> <br>
<input   type= "checkbox "   name= "aaa10 "   id= "aaa10 "> <br>
<input   type= "checkbox "   name= "aaa11 "   id= "aaa11 "> <br>
<input   type= "checkbox "   name= "aaa12 "   id= "aaa12 "> <br>
<input   type= "checkbox "   name= "aaa13 "   id= "aaa13 "> <br>
<input   type= "checkbox "   name= "aaa14 "   id= "aaa14 "> <br>
<input   type= "checkbox "   name= "aaa15 "   id= "aaa15 "> <br>
</html:form>
我现在想做的是如果str[i]中循环出有等于1的,那么复选框aaa1就选择上,没有就不选,有等于2的,复选框aaa2就勾选,否则就不选,以次类推。从数据库中取出来的数据也就是type不一定有几个。请高手指教。

------解决方案--------------------
document.all( "aaa " + str[i]).checked = true;
------解决方案--------------------
for(var i=0;i <type.length;i++)
{
str[i]=(type[i].firstChild.data).split( "@@@ ");
docuemnt.getElementById( 'aaa '+str[i]).checked = true;
}
------解决方案--------------------
up
------解决方案--------------------
for(var i=0;i <type.length;i++)
{
str[i]=(type[i].firstChild.data).split( "@@@ ");
docuemnt.getElementById( 'aaa '+str[i]).checked = true;
}

------解决方案--------------------
up