Thanks. I love expanding my horizons. :-)

On 10/1/07, Robert Koberg <[EMAIL PROTECTED]> wrote:
>
> On Mon, 2007-10-01 at 12:12 -0700, Lee Hinde wrote:
> > Hi;
> >
> > I have questions about selectors and .each.
> >
> > Given this result:
> >
> > <queryResult parent="2" queryid="C10012007113409LEQY"
> > recordsinselection="2" size="2" sortfield="" tableid="2"
> > tablename="Person">
> >   <row locked="False" recordid="[2][1]" selectionid="1">
> >       <field fieldrecordid="1" id="[2][1]">3</field>
> >       <field fieldrecordid="1" id="[2][2]">1</field>
> >       <field fieldrecordid="1" id="[2][3]">Molly</field>
> >       <field fieldrecordid="1" id="[2][4]">Hinde</field>
> >       <field fieldrecordid="1" id="[2][5]">Adult Supervision</field>
> >   </row>
> >   <row locked="False" recordid="[2][0]" selectionid="2">
> >       <field fieldrecordid="0" id="[2][1]">2</field>
> >       <field fieldrecordid="0" id="[2][2]">1</field>
> >       <field fieldrecordid="0" id="[2][3]">Lee</field>
> >       <field fieldrecordid="0" id="[2][4]">Hinde</field>
> >       <field fieldrecordid="0" id="[2][5]">Night Custodial Staff</field>
> >   </row>
> > </queryResult>
> >
> > what's the best way to iterate through to build table rows from the data?
> >
>
> It looks like there is a Sarissa plugin for jquery, so:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version="1.0">
>   <xsl:template match="/">
>     <div>
>       <xsl:apply-templates/>
>     </div>
>   </xsl:template>
>   <xsl:template match="queryResult">
>       <h1>
>         <xsl:value-of select="@tablename"/>
>       </h1>
>     <table>
>       <th>
>         <td>ID</td>
>         <td>fID</td>
>         <td>firstname</td>
>         <td>lastname</td>
>         <td>category</td>
>       </th>
>       <xsl:apply-templates/>
>     </table>
>   </xsl:template>
>   <xsl:template match="row">
>     <tr class="color{position() mod 2}">
>       <xsl:apply-templates/>
>     </tr>
>   </xsl:template>
>   <xsl:template match="field">
>     <td>
>       <xsl:value-of select="."/>
>     </td>
>   </xsl:template>
> </xsl:stylesheet>
>
>
>
>
> > I started with:
> >
> >      $j("row > field",dataXML).each(function(i){
> >                 var fID = $j(this).attr("id");
> >
> >                 if(fID=="[2][1]") {//we don't need this field, but we
> > only want to initialze once per record.
> >                     var hID = $j(this).parent().attr("recordid");
> >                     var newRow =
> > $j("<tr>").attr("class","selectableRow").attr("id","r"+i);
> >                     };//end init
> >
> >                     if(fID=="[2][3]"){
> >                         var pname = $j(this).text();
> >                         };
> >                     if(fID=="[2][4]"){
> >                          pname = pname+" "+$j(this).text();
> >                          newRow.append("<td>"+fname+"</td>");
> >                         };
> >                     if(fID=="[2][5]"){
> >                           var aRow =
> > newRow.append("<td>"+$j(this).text()+"</td>");
> >                           $j("#peopleList").append(aRow);
> >                           postDebug(pname);
> >
> >                         };
> >
> >                            })
> >
> > (figuring I'd optimize after it was working) and I was surprised that
> > "i" didn't always start at 0. Also, it seems wrong, I really want to
> > process rows, not fields. So, my question is, how do I iterate through
> > the rows and pull out the fields that I want to display.
> >
> > Starting with:
> >
> >           $j("row",dataXML).each(
> >               function(i){
> >                      var fname =
> > $j(this).$j("field").attr("id","[2][3]").text();
> >
> >
> >                           });
> > which doesn't work. Then I tried:
> >
> > var fname = this.$j("field").attr("id","[2][3]").text();
> >
> > and
> >
> > var fname =$j(this> "field").attr("id","[2][3]").text();
> >
> > neither of which worked.
> >
> > So, how do I cull out the values I need?
> >
> > Thanks for reading this far.
> >
> >  -  Lee
>
>

Reply via email to