Reputation: 5107
I'm trying to save the content from my TinyMCE text area upon submission of my form.
The body of my page has the textarea and when I hit save, there is a modal pop up with a small form of extra data to submit. When I submit though, it says the index'fulltext'
is undefined. I have this assigned to the post of the name fullText
which is assigned to my textarea but the problem is I'm not actually posting that form.
My text area is higher on the page:
<form id="form-data3" method="post">
<textarea name="fullText" id="mytextarea3"></textarea>
<input type="submit" value="Save Page" style="float:right;" data-toggle="modal" data-target="#savePageModal">
</form>
So I fill that out and I hit a save button that prompts my modal with a form that asks for a few values before submitting. Once filled out, I hit submit which triggers addPage.php but my debugging gives me the undefined indexfor 'fullText'
coming from this first line:
$content = $_POST['fullText'];
$addContent = "
INSERT INTO content(content)
VALUES('$content');
";
Obviously the issue is that my text area is in a separate form from the one posting, but even if I remove the form tags from my textarea, how can I pass that tinyMCE content of the textarea so that when I submit the form in the modal, it submits this text content as well
UPDATE:
2nd form:
<form action="addPage.php" method="post">
<input type="hidden" value="/from previous textarea">
</form>
Upvotes: 0
Views: 478
Reputation: 415
you can use ajax, and to get content of your textarea is
var content = tinyMCE.getContent('mytextarea3');
now you can post to anywhere you want.
Upvotes: 0
Reputation: 892
This is along the lines of what i was thinking.
HTML
<p><a href="#my_modal" data-toggle="modal">Open</a></p>
<div class="modal" id="my_modal">
<div class="modal-body">
<textarea class="second"></textarea>
</div>
</div>
<p><textarea class="first">First Textarea</textarea></p>
JQUERY
$('#my_modal').on('show.bs.modal', function() {
var first = $(".first").val();
$(".second").val(first);
});
View this on a jsfiddle
Upvotes: 1
Reputation: 294
Loaded model's button click event submit the form using jquery ajax
jQuery.ajax({
url: "submit.php",
data: $('#myForm').serialize() + "&textfield=" + textfieldvalue,
type: "POST",
success: function(data){
// do what ever you want
},
});
Upvotes: 0