function Switch() {
            var select = document.getElementById("LMap");
            var name = document.getElementsByName("aa");
            var i = parseInt(name);
            var mapName = select.options[i].value;
            LMap.selectedIndex = i;
            map.mapName = mapName;
            map.Update();
            select = null;
        }
<div title="aa" id="1" onclick="Switch()">点击我更换为1</div>
<div title="aa" id="2" onclick="Switch()">点击我更换为2</div>
<div title="aa" id="3" onclick="Switch()">点击我更换为3</div>
<div title="aa" id="4" onclick="Switch()">点击我更换为4</div>
<div title="aa" id="5" onclick="Switch()">点击我更换为5</div> 
就想用上面的逻辑做,id=LMap的那个不要对他操作。在这基础上改代码,求教了

解决方案 »

  1.   

    LZ代码没贴全吧?
    function Switch() {
      var select = document.getElementById("LMap");
      var name = document.getElementsByName("aa");
      var i = parseInt(name); //你把数组parseInt是啥意思?
      var mapName = select.options[i].value; 
      LMap.selectedIndex = i; //LMap 是哪来的?
      map.mapName = mapName;
      map.Update(); //Update 哪定义的?
      select = null;
      }
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    </head>
    <body>
    <script type="text/javascript">
        function Switch(id) {
            document.getElementById('slt').selectedIndex=id-1;        
        }
    </script><select id="slt">
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
    </select>
    <div title="aa" id="1" onclick="Switch(1)">点击我更换为1</div>
    <div title="aa" id="2" onclick="Switch(2)">点击我更换为2</div>
    <div title="aa" id="3" onclick="Switch(3)">点击我更换为3</div>
    <div title="aa" id="4" onclick="Switch(4)">点击我更换为4</div>
    <div title="aa" id="5" onclick="Switch(5)">点击我更换为5</div>
    </body>
    </html>