日期:2014-05-16  浏览次数:20466 次

为什么alert不到值?
页面上存在值
HTML code
开户银行:<input type="text" id="bankname"    value="中国工商银行" readonly><br/>                

                      银行帐号:<input type="text" id="banknumber" value="3344521" readonly><br/>

                      开户人:&nbsp <input type="text" id="holder"   value="含青" readonly> <br/>

                      结账方式:<select  id="way"   name="way"  >

                      

                       <option value="14"  >网上汇款</option>

                        

                       <option value="15"  >银行电汇</option>

                        

                       <option value="16"  >支票付费</option>

                        

                                      </select><br/>

                      提现金额:<input type = "text" id="withdraw"  value="4000"onkeyup="extract(this)" ; onblur ="leave(this)" ; onmouseover="this.focus(); OnEnter(this)"onmouseout="this.blur(); OnExit(this)"><br/>

                                    <input type="hidden" id="usertype" value = "1">

                                    <input type="hidden" id="withdraw1" value="4000">

                      

                 

              <div class="line m20"></div>

              <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tb3">

               

                              

                  <td><input type="submit" name="button3" id="commit" value="提交" class="btn02" />

                                    <input type="reset" name="button4" id="button4" value="取消" class="btn03"  /></td>



当点击提交时
JScript code
function commitEvent(){
    alert("ok");(可以进入到这个事件)
    var withdraw=$("withdraw").attr("value");
    var bankname=$("bankname").attr("value");
    alert(bankname);(取不到值)
    var banknumber=$("banknumber").attr("value");
    var holder=$("holder").attr("value");
    var way=document.getElementById("way").value;
    var param = {"withdraw":withdraw,"bankname":bankname,"banknumber":banknumber,"holder":holder,"way":way,"act":commit};
     $.ajax({
            type:"get",
            url:"carry_application_do.jsp",
            data:param,
            dataType:"boolean",
            success:function(s){
                if(s){
                    alert("申请成功!");
                    
                    
                }else{
                    alert("网络繁忙,请稍后在尝试!");
                    
                }
            
            }
            });


------解决方案--------------------
//jQuery?
var withdraw=$("#withdraw").val();
var bankname=$("#bankname").val();