<script language="javascript" type="text/javascript">
             //选择物料
             function opendata1(strUrl) {
                 var aa = window.showModalDialog(strUrl, window, 'dialogWidth:1030px;dialogHeight:500px;center:yes;status:no;dialogWidth:1030px;dialogHeight:500px');
                 if (aa != null) 
                 {
                     var cc = new Array();
                     cc = aa.split('|');
                     var theform = document.forms[0];
                     theform.elements["tb_matno"].value = cc[0];
                     theform.elements["tb_mname"].value = cc[1];
                     theform.elements["tb_szno"].value = cc[2];
                     theform.elements["tb_jx"].value = cc[3];
                     theform.elements["tb_spname"].value = cc[4];
                     theform.elements["tb_tongym"].value = cc[5];
                     theform.elements["tb_munit"].value = cc[6];
                     theform.elements["tb_munit1"].value = cc[7];
                     theform.elements["tb_produce"].value = cc[8];
                     theform.elements["tb_cxtj"].value = cc[9];
                     theform.elements["tb_zl"].value = cc[10];
                     theform.elements["tb_orgn_code"].value = cc[11];
                 }
                 return false;
             }
    </script>
上面的代码中,我要为各个控件赋值,前面三个可以取得,后面的就怎么也赋不进去,前提是CC[*]都是有值的,请各位帮忙,是为什么?谢谢各位了~~~functionjavascript控件

解决方案 »

  1.   

    上面变量aa的值是:'matno|mname|tongym||spname|py|munit|munit1|scqy|tj|quant|rea'; 
      

  2.   

    'matno|mname|tongym||spname|py|munit|munit1|scqy|tj|quant|rea'; 
      

  3.   

    'matno|mname|tongym|这里随便加点什么再试试|
      

  4.   

    调试的时候,alert(theform.elements["tb_spname"].value)就跳不出来提示框,而如果是alert(cc[5]),就会显示spname
      

  5.   

    IE 按F12 选脚本,刷新页面,chorme 按F12 选console,若有错误信息,点击右边错误信息地址查看
    FF 按F12 打开点控制台,如果管着就开启,然后刷新页面,点错误查看
      

  6.   

    LZ可以在代码上加上try...catch试试function opendata1(strUrl) {
        var aa = window.showModalDialog(strUrl, window, 'dialogWidth:1030px;dialogHeight:500px;center:yes;status:no;dialogWidth:1030px;dialogHeight:500px');
        if (aa != null) 
        {
            try {
            var cc = new Array();
            cc = aa.split('|');
            var theform = document.forms[0];
            theform.elements["tb_matno"].value = cc[0];
            theform.elements["tb_mname"].value = cc[1];
            theform.elements["tb_szno"].value = cc[2];
            theform.elements["tb_jx"].value = cc[3];
            theform.elements["tb_spname"].value = cc[4];
            theform.elements["tb_tongym"].value = cc[5];
            theform.elements["tb_munit"].value = cc[6];
            theform.elements["tb_munit1"].value = cc[7];
            theform.elements["tb_produce"].value = cc[8];
            theform.elements["tb_cxtj"].value = cc[9];
            theform.elements["tb_zl"].value = cc[10];
            theform.elements["tb_orgn_code"].value = cc[11];
            } catch(e) {
                alert(e);
            }
        }
        return false;
    }
      

  7.   

    各位大侠,谢谢了,找到原因了,一个猪而不能再猪的错误,tb_spname这个控件我就没命名呢。多谢各位费心,困扰了我一天了,散分结贴~~~