Sorry I got cut off. Using sDumper( $(this).parents('form') ); to dump the result visually
I can see that length = 0, and there is only one parent object - tagName = 'IMG' So to me at least it doesnt look like its doing what it should? Any further help would be great - thanks! On Tue, Aug 26, 2008 at 11:57 AM, Duncan <[EMAIL PROTECTED]> wrote: > Thanks chaps, there is no nesting of forms, I know thats invalid. Here is > what the code looks like > > <form name="SearchForm" id="SearchForm" > action="admin_ecom_product.cfm?Stage=ViewProduct" method="get" > onsubmit="return _CF_checkSearchForm(this)"> > > <table> <tr class="headerrow"> > <td colspan="12"> > > <h1>Shop > Active Products </h1> > <p><img > src="/media/pics/site/excel.jpg" name="downloadToExcel" > id="downloadToExcel"><input name="Export" id="Export" type="hidden" > value="0" /></p> > > </td> > </tr> > <!-- other form elements --> > <tr><td> > <nobr><input type="image" name="actButton" src="/media/pics/cms/display.gif" > width="62" height="16" alt="Display" class="xButton"/></nobr> > > <nobr><input type="image" > src="/media/pics/cms/showall.gif" width="62" height="16" alt="Show All" > class="xButton" onclick="ResetSearch();document.SearchForm.ShowAll.value=1;"/> > > <input type="image" > src="/media/pics/cms/reset.gif" width="62" height="16" alt="Reset" > class="xButton" onclick="ResetSearch();document.SearchForm.ShowAll.value=0;"/> > > </nobr> > > <input type="hidden" > name="PageProductStatus" value="Active"> > > <input type="hidden" > name="ShowAll" value="1"> > > > </td> > </tr> > </table > </form> > > Now in my js I have: > $().ready(function() { > $("#downloadToExcel").click(function(){ > $("#Export").val(1); > alert( $(this).parents('form').attr('id'));//returns undefined > alert( $(this).parents('form').eq(0).attr('id') );//returns undefined > }); > $(".xButton").click(function(){ > $("#Export").val(0); > }); > }); > > Using sDumper( $(this).parents('form') ); > > I can see that length = 0, > > Does it make a difference that this site is using jquery 1.2.5? > > > > On Wed, Aug 13, 2008 at 6:46 PM, Matt <[EMAIL PROTECTED]> wrote: > >> >> >> >> On Aug 13, 5:46 am, Duncan <[EMAIL PROTECTED]> wrote: >> > How do I find the id of the parent form? >> > >> >> Try: >> >> $(this).parents('form').attr('id'); >> >> You shouldn't have a form nested inside another form, so you should >> only get one form element back. >> >> If you do have the nested, you can reduce the result set to the first >> form element (the immediate parent) with eq(0): >> >> $(this).parents('form').eq(0).attr('id'); >> >> > > > -- > Duncan I Loxton > [EMAIL PROTECTED] > -- Duncan I Loxton [EMAIL PROTECTED]