If there is as little control over the markup as is implied then a
more generic solution might be applicable (untested!)?

function updateQuote(el){
  //$('form') could be cached, and may not need to store parentForm...
  var parentForm = $('form').filter(function(){
      var i = this.elements.length;
      while((i--) && this.elements[i] !== el){}
      return (i >= 0);
    });
  parentForm.attr('action', '....'); //whatever...
}

<select onchange='updateQuote(this);' .... >

Since there seems to be concern over HTML changing (without due care
and attention?) then it's possible that the structure could be changed
to place the select within one (or more) tables within the form, or
even just to make the markup valid!, which would nullify one or other
function call in parents('table:first').children('form:first').

One can only go so far, to protect other people from themselves.

On May 9, 1:54 am, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> With markup as invalid as that, it's no surprise that elements are not where
> you expect them in to be in the DOM. A FORM element can't be sandwiched in
> between a TABLE and TR like that. So the browser tries to turn this into
> something it can work with. It may shuffle things around, or just put up
> with the "incorrect" structure, or whatever. And yeah, it may be different
> from one browser to another.
>
> But I think you mentioned that you're stuck with working with the HTML as it
> is, so lucky you, you get to deal with the aftermath. :-(
>
> -Mike
>
> > ok, i'm not sure if this is the easiest way, however, this is
> > how I got the form action in the following HTML:
>
> > <table width="460" border="0" cellspacing="0" cellpadding="0">
> >    <tr valign="top">
> >            <td>
> >                    <table width="100%" border="0"
> > cellpadding="0" cellspacing="0">
> >                            <tr>
> >                                    <td valign="top" colspan="2">
> >                                            <table
> > border="0" cellspacing="1" cellpadding="3" width="100%">
> >                                                    <form
> > Method="Post" Action="phoenix.zhtml?c=69181&p=IROL-
> > irhome&t=SwitchQuote" >
>
> > <tr class="modBgQuoteShrtTicker">
>
> >    <td colspan="4" nowrap="nowrap">
>
> >            <span class="modQuoteShrtTicker">
>
> >                    <Select name="control_Symbol"
> > ONCHANGE="updateQuote(this);">
>
> >                            <option value="1"
> > SELECTED="">opt 1</option>
>
> >                            <option value="2">opt 2</option>
>
> >                    </Select>
>
> >            </span>
>
> >    </td>
> >                                                            </tr>
> >                                                    </form>
>
> > I used:
>
> > var formAction = $
> > (elm).parents('table:first').children("form:first").attr("action");
>
> > For some reason, it misses the form object on the way back
> > using "parents" so i move forward after hitting the FORM's
> > parent to get the form.  Not sure if this is browser
> > specific, but definitely a headache. (and the terrible HTML
> > syntax doesn't help either)

Reply via email to