You are not logged in.
Pages: 1
Hi All,
I've got a prblem with submitting a form using the prototype AJAx library. The form has one 'Xinha' textarea and one plain textarea, along with a couple of other fields. Once completed the form is submitted using prototype's Ajax.request method within this function which as called from an onclick event:
function submitForm(myForm,message,serverScript,reloadContent)
{
var options = {
method : 'post',
parameters : Form.serialize(myForm),
onSuccess : alert(message)
};
new Ajax.Request(serverScript, options);
doSubNav(reloadContent,'content');
}
All the data within the form is submitted successfully except the content of the xinha textarea. has anyone come across this before? I'm sure I'm being a numpty but it's starting to bug me now
Any suggestions?
CHeers
Keith
Offline
function submitForm(myForm,message,serverScript,reloadContent)
{
myForm.onsubmit(); // you have to trigger this manually, it copies the content of Xinha in the textarea
var options = {
method : 'post',
parameters : Form.serialize(myForm),
onSuccess : alert(message)
};
new Ajax.Request(serverScript, options);
doSubNav(reloadContent,'content');
}
Offline
Hi Ray,
Thanks for getting back to me so quickly
I made the change that you suggested, I now get an error: 'Object does not support this property or method' on that line. The form itself is loaded through an AJAX request updating the page content. Could this be what's causing the issue?
The elements that I'm working on are inside an admin area for a client and they have asked that I not post any URLs, but I could email information to you if you were willing to take a look.
Cheers
Keith
Offline
function submitForm(myForm,message,serverScript,reloadContent)
{
document.getElementById(myForm).onsubmit(); // you have to trigger this manually, it copies the content of Xinha in the textarea
var options = {
method : 'post',
parameters : Form.serialize(myForm),
onSuccess : alert(message)
};
new Ajax.Request(serverScript, options);
doSubNav(reloadContent,'content');
}
OK, it missed that the argument myForm is a string (as opposed to a DOM object), sorry. Please try this one
Offline
since it's prototype, you can replace document.getElementById with $ and not worry wheter it is already a DOM object or a string giving an ID and it will still reference the correct place in the DOM tree.
David G. Paul
[url]http://www.newearthonline.co.uk[/url]
Offline
Guys, that's solved it! Many many thanks!
Offline
Pages: 1