Loading ...
Sorry, an error occurred while loading the content.

Re: loop through an input field

Expand Messages
  • diodeom
    ... Your clip could be instructed to treat the ColumList input as an array to retrieve values from one by one, e.g. like that:
    Message 1 of 3 , Aug 16, 2010
    • 0 Attachment
      tom thomas <tom@...> wrote:
      >
      > I use NoteTab to write coldfusion code. I have the following clip:
      >
      > <cfset q^?[queryName:=^&] = queryNew("^?[ColumnList:=^&]")>
      > <cfset newRow = queryAddRow(^?[queryName:=^&],1)>
      > <cfset temp = querySetCell(^?[queryName:=^&],"","",1)>
      >
      > Which as an example would produce the following
      >
      > <cfset qnt = queryNew("id,name,address")>
      > <cfset newRow = queryAddRow(nt,1)>
      > <cfset temp = querySetCell(nt,"","",1)>
      >
      >
      > What I would like to do is loop through the ColumnList input to have
      > the following:
      >
      > <cfset qnt = queryNew("id,name,address")>
      > <cfset newRow = queryAddRow(nt,1)>
      > <cfset temp = querySetCell(nt,"id","",1)>
      > <cfset temp = querySetCell(nt,"name","",1)>
      > <cfset temp = querySetCell(nt,"address","",1)>
      >
      > Notice the last line of the clip is repeated but has a different
      > value - id, name or address - in this example.
      >
      > The ColumnList input will always be comma delimited. The list will be
      > different names and including the number of elements in the list.
      >
      > Thanks,
      > Tom Thomas
      >

      Your clip could be instructed to treat the ColumList input as an array to retrieve values from one by one, e.g. like that:

      <cfset q^?[queryName:=^&] = queryNew("^?[ColumnList:=^&]")>
      <cfset newRow = queryAddRow(^?[queryName:=^&],1)>
      ^!SetListDelimiter ,
      ^!SetArray %col%=^?[ColumnList:=^&]; %n%=0
      :Loop
      ^!Inc %n%
      ^!If ^%n%>^%col0% End
      ^%nl%<cfset temp = querySetCell(^?[queryName:=^&],"^%col^%n%%","",1)>
      ^!Goto Loop

      I'm not sure how to interpret your bit about including the number of elements in the list. (This figure is readily accessed by the variable at index 0, in the above sample ^%col0%.)
    • tom thomas
      This worked exactly the way I wanted it to. Thanks very much, Tom
      Message 2 of 3 , Aug 17, 2010
      • 0 Attachment
        This worked exactly the way I wanted it to.

        Thanks very much,
        Tom

        At 12:39 AM 8/17/2010, you wrote:
        >
        >
        >tom thomas <tom@...> wrote:
        > >
        > > I use NoteTab to write coldfusion code. I have the following clip:
        > >
        > > <cfset q^?[queryName:=^&] = queryNew("^?[ColumnList:=^&]")>
        > > <cfset newRow = queryAddRow(^?[queryName:=^&],1)>
        > > <cfset temp = querySetCell(^?[queryName:=^&],"","",1)>
        > >
        > > Which as an example would produce the following
        > >
        > > <cfset qnt = queryNew("id,name,address")>
        > > <cfset newRow = queryAddRow(nt,1)>
        > > <cfset temp = querySetCell(nt,"","",1)>
        > >
        > >
        > > What I would like to do is loop through the ColumnList input to have
        > > the following:
        > >
        > > <cfset qnt = queryNew("id,name,address")>
        > > <cfset newRow = queryAddRow(nt,1)>
        > > <cfset temp = querySetCell(nt,"id","",1)>
        > > <cfset temp = querySetCell(nt,"name","",1)>
        > > <cfset temp = querySetCell(nt,"address","",1)>
        > >
        > > Notice the last line of the clip is repeated but has a different
        > > value - id, name or address - in this example.
        > >
        > > The ColumnList input will always be comma delimited. The list will be
        > > different names and including the number of elements in the list.
        > >
        > > Thanks,
        > > Tom Thomas
        > >
        >
        >Your clip could be instructed to treat the
        >ColumList input as an array to retrieve values from one by one, e.g. like that:
        >
        ><cfset q^?[queryName:=^&] = queryNew("^?[ColumnList:=^&]")>
        ><cfset newRow = queryAddRow(^?[queryName:=^&],1)>
        >^!SetListDelimiter ,
        >^!SetArray %col%=^?[ColumnList:=^&]; %n%=0
        >:Loop
        >^!Inc %n%
        >^!If ^%n%>^%col0% End
        >^%nl%<cfset temp = querySetCell(^?[queryName:=^&],"^%col^%n%%","",1)>
        >^!Goto Loop
        >
        >I'm not sure how to interpret your bit about
        >including the number of elements in the list.
        >(This figure is readily accessed by the variable
        >at index 0, in the above sample ^%col0%.)
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.