hi, I not a javascritp expert and I''m trying to execute this script. Everything work as expected, except firefox does not cleanup the input boxes. I submit a form using onSubmit="sendEmail(this); return false" and IE or Opera execute and cleanup the input boxes. email.php sends and email and returns "Mensagem enviada com Sucesso!" (Message set successfully. Why firefox does not clean up the input boxes? Is there a better way to do what I want? function sendEmail(frm) { var ajax = new Ajax.Request(''/email.php'', { method: ''post'', parameters: $(''frmContact'').serialize(), onSuccess: function(transport){ var response = transport.responseText || "Sem resposta!"; alert(response); if (response == ''Mensagem enviada com Sucesso!'') { frm.nome.value = ''''; frm.email.value = ''''; frm.assunto.value = ''''; frm.mensagem.value = ''''; frm.codigo.value = ''''; } }, onFailure: function(){ alert(''Ocorreu um erro...'') } } ) }; Can you help me with this? Thanks N --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
$(''frmContact'').reset(); On Dec 11, 2007 5:05 PM, Nuno <nuno.f.neves-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > hi, > > I not a javascritp expert and I''m trying to execute this script. > Everything work as expected, except firefox does not cleanup the input > boxes. > > I submit a form using onSubmit="sendEmail(this); return false" and IE > or Opera execute and cleanup the input boxes. > > email.php sends and email and returns "Mensagem enviada com > Sucesso!" (Message set successfully. > > Why firefox does not clean up the input boxes? Is there a better way > to do what I want? > > > function sendEmail(frm) { > var ajax = new Ajax.Request(''/email.php'', > { > method: ''post'', > parameters: $(''frmContact'').serialize(), > onSuccess: function(transport){ > var response = transport.responseText || "Sem resposta!"; > alert(response); > > if (response == ''Mensagem enviada com Sucesso!'') { > frm.nome.value = ''''; > frm.email.value = ''''; > frm.assunto.value = ''''; > frm.mensagem.value = ''''; > frm.codigo.value = ''''; > } > > }, > onFailure: function(){ alert(''Ocorreu um erro...'') } > } > ) > }; > > Can you help me with this? > > Thanks > > N > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 11, 2007 4:05 PM, Nuno <nuno.f.neves-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > onSuccess: function(transport){ > var response = transport.responseText || "Sem resposta!"; > alert(response); > > if (response == ''Mensagem enviada com Sucesso!'') { > frm.nome.value = ''''; > frm.email.value = ''''; > frm.assunto.value = ''''; > frm.mensagem.value = ''''; > frm.codigo.value = ''''; > } > > }The variable frm hasn''t been defined in the context of this function when it''s called upon the AJAX request''s return. Apparently, IE and Opera search the DOM for any elements with a matching ID or NAME attribute, but Firefox doesn''t. You''ll need to do something like this: if (response == ''[SNIP]'') { var frm = $(''frm''); // assuming this is the id of the form element frm.nome.value = ''''; // proceed as before Hope that helps. :Dan Dorman --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, $(''frmContact'').reset(); solved the problem. Thanks N On Dec 11, 11:12 pm, Elden <willy...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> $(''frmContact'').reset(); > > On Dec 11, 2007 5:05 PM, Nuno <nuno.f.ne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > hi, > > > I not a javascritp expert and I''m trying to execute this script. > > Everything work as expected, except firefox does not cleanup the input > > boxes. > > > I submit a form using onSubmit="sendEmail(this); return false" and IE > > or Opera execute and cleanup the input boxes. > > > email.php sends and email and returns "Mensagem enviada com > > Sucesso!" (Message set successfully. > > > Why firefox does not clean up the input boxes? Is there a better way > > to do what I want? > > > function sendEmail(frm) { > > var ajax = new Ajax.Request(''/email.php'', > > { > > method: ''post'', > > parameters: $(''frmContact'').serialize(), > > onSuccess: function(transport){ > > var response = transport.responseText || "Sem resposta!"; > > alert(response); > > > if (response == ''Mensagem enviada com Sucesso!'') { > > frm.nome.value = ''''; > > frm.email.value = ''''; > > frm.assunto.value = ''''; > > frm.mensagem.value = ''''; > > frm.codigo.value = ''''; > > } > > > }, > > onFailure: function(){ alert(''Ocorreu um erro...'') } > > } > > ) > > }; > > > Can you help me with this? > > > Thanks > > > N--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---