hysgood
hysgood
2012-08-20 22:53

关于form表单无法将值传入程序中的问题

  • 传值
  • html
  • javascript

js代码:

function doSubmit(){
               var needaltersingles='';
               var singles = document.getElementsByName('isalter');
               var confirmname = document.getElementById('confirmname');
               for(var i =0;i<singles.length;i++){
                   if(singles[i].checked==true&&i == singles.length-1){
                     needaltersingles=needaltersingles + singles[i].value;
                   }else if(singles[i].checked==true){
                     needaltersingles=needaltersingles + singles[i].value + ";"
                   }
               }
               if(confirmname.value.length == 0){
                   alert("公司审核人不能为空!");
                   return false;
               }
               document.getElementById('needaltersingle').value=needaltersingles;
               document.form1.submit();
           } 

html代码:

<form name='form1' action="changeConfirmSingle.do" method="post">
    <input type='hidden' name='needaltersingle' id='needaltersingle' />
    公司审核人:<input type='text' name='confirmname' id='confirmname' />&nbsp;&nbsp;
    审核状态:<select name='status'>
          <option value='02' selected="selected">审核通过</option>
          <option value='03'>审核不通过,自行处理</option>
          </select>
    <input type='button' value='提交平台审核并处理' onclick='doSubmit();'>
  </form>

可以通过提交至程序中,会出现confirmname无法获取出现空指针异常的情况。

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答