Take the 2-minute tour ×

I'm trying to implement an autosave feature that submits several different forms on a page with the same name with TinyMCE'd textareas.

My code:

function autoSaveEditForms() {
$("form[name=editForm]").each(function() {

	if($('input[name="question"]', this).val() == "" || $('textarea[name="answer"]', this).val() == "")

	$.post("<?php echo $CONFIG->wwwroot; ?>action/faq/edit?autosave=true", $(this).serialize(), function(data) { 



The problem is that $('textarea[name="answer"]', this).val() does not change its value if I have two forms on the page. To clarify, if I have two forms it returns the updated value for one of them, reflecting any changes I make to the textarea, and it returns the original value of the other one (i.e.if I make any changes to one of the textareas then calling val() does not update these changes).

Is this a TinyMCE problem? Or is it necessary to do this another way?


Update: It works fine if TinyMCE is not used in the textareas.

share|improve this question
add comment

2 Answers

Its probably not a good idea to have two forms with the same name. Add a unique identifier to each form:

<form name="myform1">

<form name="myform2">

Code the event that triggers this to pass the formid it lives in:

function autoSaveEditForms($formid)
share|improve this answer
hi, i tried giving the forms and all of there elements unique ids and unique names to no avail. any other ideas? I'm up the creek on this one.. I guess it's a tinyMCE problem. –  Eric Conner Jul 28 '09 at 4:03
This should allow you to access the different forms document.myform1... document.myform2... Try the javascript debugger in firefox (CTL + Shift + J) and look at the error message. –  NW Architect Aug 4 '09 at 23:58
add comment
up vote 0 down vote accepted

Ok got it. Turns out you cannot access the data in the usual jquery way. Initialize TinyMCE in this fashion:

  mode : "none",
  theme : "advanced"

/* call this function in ajax return text */
function makeTinyMCE(faqid) {
	tinyMCE.execCommand('mceAddControl', false, 'answer'+faqid);


Then grab the text in this way:

share|improve this answer
add comment

Your Answer


