Christophe Porteneuve wrote:> Hey,
>
> cpoteet a écrit :
> > document.frmMain.action >
> BTW, you do know "document.someElementId" is IE-specific, right?
Other browsers support it too, though not all. document.formName will
work in more browsers than getElementById(''formId'').
> If you
> need portability, that won''t do. Use
$(''frmMain'') instead, and make
> sure your form has a ID attribute with value "frmMain".
Or use a name attribute, or document.forms[''frmMain''], which
will work
in more browsers than $(), whether frmMain is a name or id (use both to
get right back to very old browsers) and is considerably faster to
boot.
> >
"handler.asp?Filter=<%=strFilter%>&action=DelUser";
> > document.frmMain.inpUser.value = id;
> > document.frmMain.inpCoP.value = copid;
> > document.frmMain.submit();
>
> Using a ''with'' block would help here, too.
with is not much liked, a better solution is to keep a local reference
to the form and use that:
var form = document.forms[''frmMain''];
form.inpUser.value = id;
...
> > <a class="text" href="javascript:delete_click(id,
''name'', copid,
>
> Similary, there''s no standard definition/implementation for
javascript:
> URL schemes. At the very least, use onclick handlers for this, and make
> them return false and/or prevent default event handling.
Also worth noting that using a link and the javascript pseudo-protocol
also has unfortunate consequences in IE.
If a button in a form is used, a reference to the form can be obtained
without resorting to getElementById (even if wrapped in $()) or the
forms collection.
> > I want to use this inside of the Ajax function, but I don''t
know how to
> > integrate. Also, I would like to, after HTTP request is made, to
> > remove that element (which is a <td>).
Simply removing a td element from a table may have unexpected
consequences, you should probably delete just the cell content, or
remove the entire row.
> What exactly do you mean by that? Do you mean to say you''d like
to
> migrate from your form submission to an AJAX request? Or something else?
A good strategy is to use a form and onsubmit handler so that if
appropriate features are detected, they are used and form submission
cancelled. If not, or if scripting is not available at all, the form
submits and the request is satisfied that way.
If the OP already has appropriate functionality coded using a form,
then all that is required is an onsubmit handler on the form that does
the job with AJAX (or other asynchronous method, XMLHttpRequest is just
one) and cancels submission:
<form id="frmMain" action="..." onsubmit="return
doOnsubmit(this);" >
...
<input type="submit" value="Delete user">
</form>
and in the onsubmit function:
function doOnsubmit( formRef ){
/* do stuff with the form */
if ( /* all went to plan */ ) {
return false;
}
return true;
}
--
Fred
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---