Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/437.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript BIRT如何获取表名?_Javascript_Report - Fatal编程技术网

Javascript BIRT如何获取表名?

Javascript BIRT如何获取表名?,javascript,report,Javascript,Report,在我的报告设计的布局中,我有一个标签、表格和HTML按钮。 如何使用HTML按钮的OnClick事件从表、标签等中获取值? 使用elementname.getValue无法轻松访问表和标签;我错过什么了吗? 谢谢。好的,这个解决方案可以根据您实际的表结构以及您需要的实际信息进行修改。您可以通过许多不同的方式来实现这一点,但此解决方案利用从表中获取label元素和“td”单元格以及样式。你可以在这里看到一个,我做的,使之可视化。如果它不适合您的需要,我建议您查看jQueryAPI来修改您应该如何准

在我的报告设计的布局中,我有一个标签、表格和HTML按钮。 如何使用HTML按钮的OnClick事件从表、标签等中获取值? 使用elementname.getValue无法轻松访问表和标签;我错过什么了吗?
谢谢。

好的,这个解决方案可以根据您实际的表结构以及您需要的实际信息进行修改。您可以通过许多不同的方式来实现这一点,但此解决方案利用从表中获取label元素和“td”单元格以及样式。你可以在这里看到一个,我做的,使之可视化。如果它不适合您的需要,我建议您查看jQueryAPI来修改您应该如何准确地获取所需的数据

这是HTML:

<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<body>
    <label id="label">This is my Table</label>
    <table class="table table-striped">
         <thead>
              <tr>
                  <th>Row</th>
                  <th>First Name</th>
                  <th>Last Name</th>
                  <th>Email</th>
              </tr>
         </thead>
         <tbody>
             <tr>
                 <td>1</td>
                 <td>John</td>
                 <td>Carter</td>
                 <td>johncarter@mail.com</td>
            </tr>
            <tr>
                 <td>2</td>
                 <td>Peter</td>
                 <td>Parker</td>
                 <td>peterparker@mail.com</td>
           </tr>
           <tr>
                <td>3</td>
                <td>John</td>
                <td>Rambo</td>
                <td>johnrambo@mail.com</td>
            </tr>
        </tbody>
    </table>

    <button type="button" id="getInfo" class="btn btn-primary">Get Info</button>

    <br/>
    <p>Your Results Object once you hit Get Info button</p>
    <div id="results"></div>

    <!-- Get jQuery -->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

</body>
</html>

到目前为止,请提供您的代码或创建一个。my rptdesign只包含一个label元素、table元素和一个HTML按钮。我只想知道如何使用HTML按钮访问表和标签中的数据。
// This solution uses jQuery
// A $( document ).ready() block.
$( document ).ready(function() {

    // declares an object literal named 'results' to save future results
    // declares an array literal named 'tableData' to save table data
    var results = {},
        tableData = [];

    // this executes once you click 
    // the HTML button with ID '#getInfo'
    $('#getInfo').click(function() {

        //loop through each 'td' cell which has information
        $('td').each(function() {
            var value = $(this).text();
            tableData.push(value);
        });

         // assign the label to object 'results' with property label
         results.label = $('#label').text();

         results.tableData = tableData;

         document.getElementById("results").innerHTML = 
                       JSON.stringify(results);  

    });

});