当前位置: 代码迷 >> JavaScript >> 关于一个split的有关问题()
  详细解决方案

关于一个split的有关问题()

热度:82   发布时间:2012-03-09 16:54:57.0
关于一个split的问题(在线等)
<js>
//////////
var   str00= "aa00|bb00|cc00 ";
var   arrLocation=str00.split( "| ");
for(var   i=0;i <arrLocation.length;i++)
{
alert(arrLocation[i]);//能得到aa00,bb00,cc00
alert(document.all.aa00.value);//能得到34
alert(document.all.arrLocation[i].value);//报错!


}
/////////////////
<input   type= "text "   name= "aa00 "   value= "34 ">  
<input   type= "text "   name= "bb00 "   value= "35 ">  
<input   type= "text "   name= "cc00 "   value= "36 ">  


///////////////////
那个老大帮帮忙,

------解决方案--------------------
var str00= "aa00|bb00|cc00 ";
var arrLocation=str00.split( "| ");
for(var i=0;i <arrLocation.length;i++)
{
alert(document.getElementById(arrLocation[i]).value);//报错!


}
/////////////////
<input type= "text " id= "aa00 " name= "aa00 " value= "34 ">
<input type= "text " id= "aa00 " name= "bb00 " value= "35 ">
<input type= "text " id= "aa00 " name= "cc00 " value= "36 ">
------解决方案--------------------
<input type= "text " id= "aa00 " name= "aa00 " value= "34 ">
<input type= "text " id= "aa00 " name= "bb00 " value= "35 ">
<input type= "text " id= "aa00 " name= "cc00 " value= "36 ">

<script type= "text/javascript ">
var str00= "aa00|bb00|cc00 ";
var arrLocation=str00.split( "| ");
for(var i=0;i <arrLocation.length;i++)
{
alert(document.getElementById(arrLocation[i]).value);
}
</script>

没错啊~
  相关解决方案