zoukankan      html  css  js  c++  java
  • JS获取一行2列的表格数据

    JS如下:

    如何在JS中获取下拉框中的value和Text值呢?

    获取Text值:

    document.getElementById(s[0]).options[window.document.getElementById(s[0]).selectedIndex].Text;

    获取value值:

    document.getElementById(s[0]).options[window.document.getElementById(s[0]).selectedIndex].value

    s[i] 数组中保护3个数据项:主键ID,控件ID,控件类型。

        function createTasks() {
            if (Page_ClientValidate()) {
                var rows = document.getElementById('EidtTable').rows;
                var result = '';
                var str = "<%=str%>"
                var arry = str.split(";");
                for (var i = 0; i < arry.length; i++) {
                    var s = arry[i].split(",");
                    switch (s[1]) {
                        case "TextBox":
                            var rowString = s[2]+"_"+document.getElementById(s[0]).value + ',';
                            break
                        case "radiobuttonlist":
                            var list = document.getElementById(s[0]).getElementsByTagName("input");
                            var strData = "";
                            for (var j = 0; j < list.length; j++) {
                                if (list[j].type == "radio") {
                                    if (list[j].checked) {
                                        var rowString = s[2] + "_" + list[j].value + ',';
                                    }
                                }
                            }
                            break;
                        case "TexBoxM":
                            var rowString = s[2] + "_" + document.getElementById(s[0]).value + ',';
                            break
                        case "DateTime":
                            var rowString = s[2] + "_" + document.getElementById(s[0]).value + ',';
                            break
                        case "FileUpload":
                            var rowString = s[2] + "_" + document.getElementById(s[0]).value + ',';
                            break
                        case "DropDownList":
                            var rowString = s[2] + "_" + document.getElementById(s[0]).options[window.document.getElementById(s[0]).selectedIndex].value + ',';
                            break
                        case "Hdf":
                            var hdf1 = document.getElementById(("hdf" + s[0] + "0")).value;
                            var hdf2 = document.getElementById(("hdf" + s[0] + "1")).value;
                            var rowString = s[2] + "_" + hdf1 + "-" + hdf2 + ',';
                            break
                        default:
                            break;

                    }
                    result = result + rowString;
                 
                }
                document.getElementById("hdfValues").value = result;
              
            }

        }

  • 相关阅读:
    博客园界面部分优化
    jQuery获取Select选择的Text和 Value
    java开发各层对象含义
    接口与抽象类的区别(完整描述)
    Map相关知识总结
    html引用外部js和css
    RDD内存迭代原理(Resilient Distributed Datasets)---弹性分布式数据集
    spark高可用集群搭建及运行测试
    spark集群的简单测试和基础命令的使用
    spark集群搭建
  • 原文地址:https://www.cnblogs.com/Jack_G/p/2683059.html
Copyright © 2011-2022 走看看