0

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.

3
  • in case of java script what value you are getting in php ? Sep 5, 2013 at 19:14
  • in case of java script i am getting "Value of textarea." Sep 5, 2013 at 19:16
  • see my answer hope that will work for you... Sep 5, 2013 at 19:19

2 Answers 2

0

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.

5
  • Yes, this is solved that problem. But my textarea is a html text editor and this disturbed the formatting. Sep 5, 2013 at 19:34
  • I didn't get you..Once you have striped out the tags how can they will come again ? Sep 5, 2013 at 19:37
  • Actually, textarea is html editor and storing data in DB without html tag and getting back the html tag by using markdown script. if i striped then markdown script is not working.. Sep 5, 2013 at 19:46
  • So waht do you want?? first you asked to remove the automatically generated p tag and now ?? Sep 5, 2013 at 19:50
  • so let them go as it is Sep 5, 2013 at 20:00
0

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.

1
  • My php code getting value through $_POST['rte1'] and this value i am storing in DB. Sep 5, 2013 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.