在ascx页面使用js获取radiobuttonlist的值

  function GetInputValue()
    {
        var TBBidPrice=document.getElementById("<%=TBBidPrice.ClientID %>").value;
        return TBBidPrice;
    }
    function GetRadio(tagname)
    { 
        var input =document.getElementsByTagName("input");//获取所有input标签
        for(var i=0;i<input.length;i++)
        {
            //判断是否是radio
            if(input[i].type=="radio")
            {
                //如果tag名称相同 则找到对应的radio标签
                if(input[i].name.indexOf(tagname)>0)
                {               
                   //获取radiobuttonList标签 
                   radio =document.getElementsByName(input[i].name);
                   for(var j=0;j<radio.length;j++)
                   {
                     if(radio[j].checked==true)
                     {
                        //寻找radio里的下一个标签
                        var nextEle = radio[j].nextSibling;
                        //判断找到label标签
                        if(nextEle.tagName.toLowerCase() == "label")
                         {
                            //获取值label的值
                            var Label = nextEle.innerText;
                            var hetongjia = GetInputValue();
                            var laobaofei;
                            if(hetongjia!=null&& hetongjia!="")
                            { 
                                if(Label!="其他")
                                {
                                        laobaofei = parseFloat(Label)*parseFloat(hetongjia)*parseFloat(0.01);
                                        document.getElementById("<%=TBJiGouAllCost.ClientID %>").value=laobaofei.toFixed(2);
                                } 
                                else
                                 {
                                        var otherValue = document.getElementById("<%=TBOtherTongChouRate.ClientID %>").value;
                                       
                                        if(otherValue != null && otherValue != ""){
                                           var hetongtemp = GetInputValue();
                                           laobaofei = parseFloat(otherValue)*parseFloat(hetongtemp)*parseFloat(0.01);
                                           document.getElementById("<%=TBJiGouAllCost.ClientID %>").value=laobaofei.toFixed(2);
                                        }else{
                                            alert("请输入劳保费率");
                                        }
                                   } 
                              } 
                           
                          }
                       }
                   }
                   return;
                }
            }
        }
    } 
posted @ 2011-04-11 18:31  辰冉  阅读(1068)  评论(0编辑  收藏  举报