[英]Pass the value from a textarea to PHP
I want to pass the text I enter in to a textarea
to a PHP function.我想将输入到文本区域的textarea
传递给 PHP 函数。
console.log($('#notes').val()); let report = { notes: $('#notes').val() }; //this.userData.addMediaReport(report)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <textarea id="notes" rows="4" cols="50">Lorem ipsum</textarea>
console.log
returns undefined
. console.log
返回undefined
。 Any ideas?有任何想法吗?
put the $('#notes').val() code inside the form submit event.将 $('#notes').val() 代码放入表单提交事件中。
$(document).ready(function(){
$( "form" ).submit(function( event ) {
let report = {
notes: $('#notes').val()
};
});
});
Make sure the textarea exists and contains the required value before it is accessed.在访问之前确保文本区域存在并包含所需的值。
I want to pass the text I enter in to a textarea
to a PHP function.我想将我输入到textarea
传递给 PHP 函数。
console.log($('#notes').val()); let report = { notes: $('#notes').val() }; //this.userData.addMediaReport(report)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <textarea id="notes" rows="4" cols="50">Lorem ipsum</textarea>
console.log
returns undefined
. console.log
返回undefined
。 Any ideas?有任何想法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.