简体   繁体   中英

Html tag automatically added textarea value if form submitted through Jquery

Html tag automatically added textarea value if form submitted through Jquery.

My jquery code.

$('#calling').click(function() {
    $('#myform').submit();
});

In my form one text area is there.

<textarea id="area" name="rte1" cols="50" rows="10">Value of textarea.</textarea>

Javascript code as below.

document.myform.submit();

In case of jquery form submit i am getting textarea value in PHP as

<p>Value of textarea.</p>

But in case of java script form submit i am getting the proper value in php.

Please suggest what is the problem with my jquery code.

Well a simple way in php to get the value without any HTML Tag

$textarea = strip_tags($_REQUEST['rte1']);

This will return you Value of textarea. without <p> tags.

See Manual if you need any more help.

There is no problem at all with your jquery code. Tested with POST and GET methods and the server only gets the "Value of textarea." string. You must have something wrong in your PHP.

http://jsfiddle.net/sftHD/

document.myform.submit();
$('#myform').submit();

Those produce the same result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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