Forum Moderators: coopster
I am integrating xajax and fckeditor, ie, i am updating my db with the values of the fckeditor through ajax.
Everything works fine except that the fckeditor's value get updated when i submit the form twice.
So, I wanted to know if i can in any way submit the form twice if the user clicks on the submit button only once.
Here is the code for the front end page :
<form action="javascript:void(null);" method="POST" name="edit_template" id="edit_template" onSubmit="return DoSubmit(this, 'EditTemplate', 'Editing Template', false, 'response');">
<label for="from_name"> Sender Name : </label> <input type="text" value="%FROM_NAME%" name="from_name" id="from_name" />
<br />
<br />
<label for="from_email"> Sender Email : </label> <input type="text" value="%FROM_EMAIL%" name="from_email" id="from_email" />
<br />
<br />
<label for="subject"> Subject : </label> <input type="text" value="%SUBJECT%" name="subject" id="subject" />
<br />
<br />
<label for="email_template"> Email Template : </label> <br />%RTE%
<br />
%RTE% is parsed as i am using a template based system.
Here is the code for the back end part:
function EditTemplate($formvalues)
{
global $Message, $DBConnection, $Functions, $Template, $session_user_id, $emailTemplate;
$objResponse = new xajaxResponse();
if (trim($formvalues[from_name]) == "") {
$response = "Please enter a name for sender";
} elseif ( !$Functions->CheckEmail($formvalues[from_email])) {
$response = "Please enter a valid sender email address";
} elseif (trim($formvalues[subject]) == "") {
$response = "Please enter a subject";
} elseif (trim($formvalues[email_template]) == "") {
$response = "Please enter some body text for the email.";
} else {
$updateArray = array
(
'from_name'=> $formvalues[from_name],
'from_email'=> $formvalues[from_email],
'subject'=> $formvalues[subject],
'email_template'=> $formvalues[email_template]
);
$DBConnection->UpdateRecord('mldc_configemails', $updateArray, "name='".$formvalues[email_name]."'");
$response = "Success";
}
$objResponse->assign('response', 'innerHTML', $response);return $objResponse;
}
Any help will be highly appreciated!
Thanks in advance!
This isn't expected behavior, is it? Instead of working with this behavior, why don't you fix this problem?
If the info is not working on the first submit then the problem is probably javascript related, not php related.