<script type="text/javascript">
var tmp="{&quot;moto&quot;:[&quot;1200&quot;,&quot;3300&quot;],&quot;nokia&quot;:[&quot;N73&quot;,&quot;N96&quot;],&quot;sony&quot;:[&quot;K508C&quot;]}";
alert(tmp.replace(/&quot;/g,"\""));
</script>

解决方案 »

  1.   

    过滤函数function change(strvalue){
    strvalue = strvalue.replace(/&amp;/g,"&");
    strvalue = strvalue.replace(/&lt;/g,"<");
    strvalue = strvalue.replace(/&gt;/g,">");
    strvalue = strvalue.replace(/&quot;/g,"\"");
    strvalue = strvalue.replace(/&#39;/g,"'");
    return strvalue;
    }
      

  2.   


    <script language='javascript'>
    var sas = '{&quot;moto&quot;:[&quot;1200&quot;,&quot;3300&quot;],&quot;nokia&quot;:[&quot;N73&quot;,&quot;N96&quot;],&quot;sony&quot;:[&quot;K508C&quot;]}'; var tempsys = new Array(); tempsysaa = change(sas); alert(tempsysaa); tempsys = tempsysaa;
    function mm()
    {
    var mmname = "<select name='mmb' id='mmb' onchange='selchange(tempsys[this.value])'>";
    for(var i in tempsys)
    {
    mmname +=  "<option value="+i+">"+i+"</option>";
    }
    mmname += "</select>";
    document.getElementById('mm').innerHTML = mmname;
    }
        function selchange(sObj)
        {
            var sonname = "<select name='son' id='son'>";
            for(var i in sObj)
            {
                sonname += "<option value="+sObj[i]+">" + sObj[i] + "</option>";
            }
            sonname += "</select>";
            document.getElementById('mx').innerHTML = sonname;
        } function change(strvalue)
    {
    strvalue = strvalue.replace(/&amp;/g,"&");
    strvalue = strvalue.replace(/&lt;/g,"<");
    strvalue = strvalue.replace(/&gt;/g,">");
    strvalue = strvalue.replace(/&quot;/g,"\"");
    strvalue = strvalue.replace(/&#39;/g,"'");
    return strvalue;
    }</script>
    <body onload="mm()"> <div id='mm' name='mm'>
    </div>
    <div id='mx' name='mx'>
    </div>
    </body>
    这是我想实现的一种级联  发现最终实现不了。。怎么搞啊?
      

  3.   

    <script language='javascript'>
        var sas = '{&quot;moto&quot;:[&quot;1200&quot;,&quot;3300&quot;],&quot;nokia&quot;:[&quot;N73&quot;,&quot;N96&quot;],&quot;sony&quot;:[&quot;K508C&quot;]}';
        var tempsys = new Array();
        tempsysaa = change(sas);
        eval('var tempsys = ' + tempsysaa);
        function mm()
        {
            var mmname = "<select name='mmb' id='mmb' onchange='selchange(tempsys[this.value])'>";
    mmname +=  "<option value='囧'>请选择</option>";
            for(var i in tempsys)
            {
                mmname +=  "<option value='"+i+"'>"+i+"</option>";
            }
            mmname += "</select>";
            document.getElementById('mm').innerHTML = mmname;
        }
            function selchange(sObj)
        {
            var sonname = "<select name='son' id='son'>";
            for(var i in sObj)
            {
                sonname += "<option value="+sObj[i]+">" + sObj[i] + "</option>";
            }
            sonname += "</select>";
            document.getElementById('mx').innerHTML = sonname;
        }    function change(strvalue)
        {
            strvalue = strvalue.replace(/&amp;/g,"&");
            strvalue = strvalue.replace(/&lt;/g,"<");
            strvalue = strvalue.replace(/&gt;/g,">");
            strvalue = strvalue.replace(/&quot;/g,"\"");
            strvalue = strvalue.replace(/&#39;/g,"'");
            return strvalue;
        }</script>
    <body onload="mm()"> 
    <div id='mm' name='mm'>
    </div>
    <div id='mx' name='mx'>
    </div>
    </body>
    关键是要,将字符串转成对象
    eval('var tempsys = ' + tempsysaa);
      

  4.   


    <script language='javascript'>
        var sas = '{&quot;moto&quot;:[&quot;1200&quot;,&quot;3300&quot;],&quot;nokia&quot;:[&quot;N73&quot;,&quot;N96&quot;],&quot;sony&quot;:[&quot;K508C&quot;]}';

        var tempsys = new Array();    tempsysaa = change(sas);
    var tempsysaa=eval('('+tempsysaa+')')
    ;
          tempsys    = tempsysaa;    function mm()
        {
            var mmname = "<select name='mmb' id='mmb' onchange='selchange(tempsys[this.value])'>";
            for(var i in tempsys)
            {
                mmname +=  "<option value="+i+">"+i+"</option>";
            }
            mmname += "</select>";
            document.getElementById('mm').innerHTML = mmname;
        }
            function selchange(sObj)
        {
            var sonname = "<select name='son' id='son'>";
            for(var i in sObj)
            {
                sonname += "<option value="+sObj[i]+">" + sObj[i] + "</option>";
            }
            sonname += "</select>";
            document.getElementById('mx').innerHTML = sonname;
        }    function change(strvalue)
        {
            strvalue = strvalue.replace(/&amp;/g,"&");
            strvalue = strvalue.replace(/&lt;/g,"<");
            strvalue = strvalue.replace(/&gt;/g,">");
            strvalue = strvalue.replace(/&quot;/g,"\"");
            strvalue = strvalue.replace(/&#39;/g,"'");
            return strvalue;
        }</script>
    <body onload="mm()"> <div id='mm' name='mm'>
    </div>
    <div id='mx' name='mx'>
    </div>
    </body>