简体   繁体   English

HTML表格可以通过表单传递并通过post获得值吗?

[英]Can an HTML table be passed in form and get the value through post?

Is it possible to pass the value of an HTML table through post or not? 是否可以通过post传递HTML表的值? I'm making a PDF report, and want to get only in my HTML table. 我正在制作PDF报告,并且只想获取我的HTML表。

是的,请使用textarea提交html内容

sure, just create a valid form and send the content .. 当然,只需创建一个有效的表格并发送内容即可。

<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    </head>
    <body>
        <form id="f">
            <input type="hidden" name="mytable" />
            <button>Submit</button>

        </form>

        <table id="t">
            <tr>
                <td>ra ra</td>

            </tr>

        </table>

    </body>

    <script>
    $(document).ready( function() {
        $('#f').on( 'submit', function( e) {
            let t = $('#t');

            $('input[name="mytable"]', this).val( t[0].outerHTML)
            console.log( $(this).serializeArray());

            return false;

        });

    });
    </script>

</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM