Thanks for the tip hj. Is that a cross-browser solution? I tested it
in FF and got the absolute URL, but in IE it returns the relative
URL.

I used

var formAction = $(elm.form).attr("action");

and that will return the same in both browsers, however I'd still like
to know how reliable that is. Thanks.

Brian.

On May 9, 10:37 am, hj <[EMAIL PROTECTED]> wrote:
> > Could you possibly just give your form an id attribute?  Then onchange you
> > could just return $("#myformid").attr("action") and not have to mess with
> > any traversing.
>
> > -- Josh
>
> > ----- Original Message -----
> > From: "briandichiara" <[EMAIL PROTECTED]>
> > To: "jQuery (English)" <jquery-en@googlegroups.com>
> > Sent: Thursday, May 08, 2008 1:58 PM
> > Subject: [jQuery] Re: Getting Parent Element using "this"
>
> > > Ok, I tried this:
>
> > > $(elm).parents().map(function () {
> > > alert(this.tagName);
> > > });
>
> > > but the FORM never shows up. Reason is because the source looks like
> > > this:
>
> There's no need for any of this; elements of a form (input, select,
> textarea) has a "form" property, so:
>
>   <form action="something">
>   <select name="some_name" onchange="changeAction(this);">
>   <!-- some options -->
>   </select>
>   </form>
>
>   function changeAction(elm){
>       var formAction = elm.form.action;
>       ...
>   }
>
> And, as others have suggested, it's a better practice to do this all
> in JavaScript, so that becomes:
>
>   <form  action="something">
>   <select id="some_select" name="some_name">
>   <!-- some options -->
>   </select>
>   </form>
>
>   jQuery(document).ready(function() {
>     jQuery('select#some_select').change(function() {
>       var formAction = this.form.action;
>       ...
>     });
>   });
>
> --
>
> hj

Reply via email to