javascript 数组使用

---------------------------------------------------------------------------------------------------------------------

<script type="text/javascript">
var data = [
["请选择"],
["明星日志","影音评论","娱乐八卦","影音播客","选秀地带","片场传真"],
["车坛观察站","网友车生活","开心自驾游","海外车友风","技术大讲堂","赛道狂飙族"],
["时尚视点","情感两性","同性同志","潮流风尚"]
];

var data_value = [
["请选择"],
["明星日志","影音评论","娱乐八卦","影音播客","选秀地带","片场传真"],
["车坛观察站","网友车生活","开心自驾游","海外车友风","技术大讲堂","赛道狂飙族"],
["时尚视点","情感两性","同性同志","潮流风尚"]
];

 

function change(x)
{
        var d = data[x];
  var d_v=data_value[x]
        with (document.myform.elements["ud_6"])
  {
                length = 0;
                for(i=0;i<d.length;i++)
                        options[i] = new Option(d[i],d_v[i]);
        }
       
  }     
        </script>

 

 

//使用

<form id="myform" name="myform">
<p>文章大类:<select size="1" name="ud_5" onChange="change(this.selectedIndex)">
       <option>请选择</option>
       <option value="娱乐">娱乐</option>
       <option value="汽车">汽车</option>
       <option value="女性">情感</option>   
      </select>
      文章小类:<select size="1"  name="ud_6"><option></option></select>
                        </p>
                        </form>

 

-------------------------------------------------------------------------------------------------------------------

 

 var pics = [
   
    {
        picID: 'b24d33db085eb87ad1164e22',
        picOper: 0,
        picSize: '29121',
        picWidth: '500',
        picHeight: '661',
        picDate: '2008-11-29',
        picDes: '无标',
        userName: '淡紫韵律',
        userNameUrl: '%B5%AD%D7%CF%D4%CF%C2%C9'
    }
    ,
   
    {
        picID: '0841953d5d7e3b1cbba16721',
        picOper: 0,
        picSize: '27259',
        picWidth: '500',
        picHeight: '632',
        picDate: '2008-11-29',
        picDes: '无',
        userName: '淡紫韵律',
        userNameUrl: '%B5%AD%D7%CF%D4%CF%C2%C9'
    }
}

 

取值:

pics[索引值]["picID"]

 

 

你可能感兴趣的:(JavaScript,娱乐,生活,function,情感,八卦)