zoukankan      html  css  js  c++  java
  • js服务器端控件Label 与TextBox RadioButtonList 与 DropDownList 的值

    大多数的 控件他的值都可以通过js调用它的 value属性来获得此控件的值,但是也有例外的情况。

    经常用的 Label控件。他的值用js就不能通过value属性来获得。

       Label控件 js获取的实例, var text= document.getElementById('Label1').innerText;

    假如, 这样 var text= document.getElementById('Label1').value; 则 text 为Undefined。

    TextBox 的值 就可以 var text= document.getElementById('TextBox 1').value;

    对于,RadioButtonList 与 DropDownList 他们的获取方式是大不一样的! 这主要是因为 他们所生成的 html元素不一样。

    DropDownList 的值 获取 比较简单:

            var ddlvalue = document.getElementById('ctl00_Contentplaceholder3_ddlFolws').value;
           

    而 RadioButtonList 的值获取 就比较麻烦:

            var value = "";

            var Result = document.getElementsByName('ctl00$Contentplaceholder3$rblResult');
            for (var i = 0; i < Result.length; i++) {
                if (Result.item(i).checked) {
                    value = Result.item(i).value;
                }
            }

    如果 RadioButtonList 控件 没有一个选择的 那么 value的值 为空!

  • 相关阅读:
    H5 坑
    小程序上传图片
    小程序瀑布流
    vue 使用插件
    fastclick:处理移动端click事件300毫秒延迟
    h5知识总结
    vue 瀑布流实现
    vue组件 $children,$refs,$parent的使用详解
    vue轮播插件vue-awesome-swiper
    JS判断是否在微信浏览器打开
  • 原文地址:https://www.cnblogs.com/guanjie20/p/1592344.html
Copyright © 2011-2022 走看看