当前位置: 代码迷 >> JavaScript >> 为何下面代码中无法取得返回值
  详细解决方案

为何下面代码中无法取得返回值

热度:83   发布时间:2013-10-15 16:47:37.0
为什么下面代码中无法取得返回值
<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[*]都是有值的,请各位帮忙,是为什么?谢谢各位了~~~
function javascript 控件

------解决方案--------------------
如果值都有,要么画面的元素找不到。你调试下吧。
------解决方案--------------------
IE 按F12 选脚本,刷新页面,chorme 按F12 选console,若有错误信息,点击右边错误信息地址查看
FF 按F12 打开点控制台,如果管着就开启,然后刷新页面,点错误查看
------解决方案--------------------
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];
  相关解决方案