简体   繁体   English

如何发送文本区域的内容?

[英]How may I send the content of a textarea?

How may I send the content of the description textarea? 如何发送description文本区域的内容?

Here is my code: 这是我的代码:

HTML: HTML:

   <form action="foo?idA=140" id="formu" method="post">    
      <div class="modal fade" id="rpopup" hidden>
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="titred"><small>Veuillez décrire brièvement ce que vous avez fait</small></h4>
                </div>
                <div class="modal-body">
                    <textarea id="description" cols="90" rows="5" maxlength="200" style="border:0px;" autofocus required></textarea>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
                    <button type="button" class="btn btn-success" id="submitd">Valider</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</form>

Javascript: Javascript:

    <script>
        $('#re').on('click', function (e) {
            $('#rpopup').modal('show');
        });
        $("#submitd").click(function () {
            $("#formu").submit();
        });
    </script>

When I fill that and I send it I get an undefined value. 当我填写并发送它时,我得到一个undefined值。 How do I to deal with this, please? 请问我该如何处理?

Thanks a lot! 非常感谢!

While using form to submit data, you have to use name attribute for all input fields. 使用表单提交数据时,必须对所有输入字段使用name属性。

<textarea id="description" name="description" cols="90" rows="5" maxlength="200" style="border:0px;" autofocus required></textarea>

Then, you can access this value in the action page using the name of the textarea, 然后,您可以使用文本区域的名称在操作页面中访问此值,

$_POST['description'];

Just give a name to the textarea , then the contents of the textarea will be sent as a request params along with any other form data. 只需给textarea指定一个名称 ,然后textarea的内容将作为请求参数与任何其他表单数据一起发送。 You can access it in the server from the request object using the name you gave to the textarea 您可以使用为文本区域指定的名称从请求对象在服务器中访问它

<textarea id="description" name="description" cols="90" rows="5" maxlength="200" style="border:0px;" autofocus required></textarea>

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

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