Before we start, note this:
http://www.w3schools.com/tags/att_standard_id.asp which says that an ID must
begin with a letter.  So you are going to need to modify your HTML so that
your ID values are letter then number.  Chances are, this is your whole
problem.

var list = /* JSON array */

for ( var i = 0 ; i < list.length ; i++ ) {
  var id = 'img' + ( i + 1 );  // assumes div ID's are 'img1' and 'img2' and
so forth.  Adjust accordingly
  var img = document.createElement( 'img' );
  $(img).attr('src') = list[i];
  $('#filmstrip ' + id).append( img );
}

There are many ways to do this, the above code is just a clean, instructive
way of doing it.

On Mon, Jan 11, 2010 at 9:30 PM, Randall Morgan <rmorga...@gmail.com> wrote:

> Here is a print out of the Json array returned from my php script.
>
>
> ["http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0853.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0855.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0856.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0857.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0858.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0860.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0859.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0861.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0862.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0863.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0864.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0847.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0849.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0851.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0845.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0846.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0850.JPG","http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0848.JPG"]
>
> Thank you for you help
>
> On Mon, Jan 11, 2010 at 10:25 PM, John Arrowwood <jarro...@gmail.com>
> wrote:
> > What does your JSON array look like?
> >
> > On Mon, Jan 11, 2010 at 9:23 PM, Randall Morgan <rmorga...@gmail.com>
> wrote:
> >>
> >> Hello,
> >>
> >> I'm still pretty new to JQuery and I need to figure out how to loop
> >> over a json array and assign the array values to each of a list of
> >> divs. What I need to do is fill each filmstrip-cell with an image tag
> >> and set the source to the current value in the array. The array
> >> contains urls for each of 35 images.
> >>
> >> My code is similar to:
> >>
> >> <div id="filmstrip" class="filmstrip">
> >>   <div id="1" class="filmstrip-cell"
> >>   </div>
> >>  <div id="2" class="filmstrip-cell"
> >>   </div>
> >>  <div id="3" class="filmstrip-cell"
> >>   </div>
> >>  <div id="4" class="filmstrip-cell"
> >>   </div>
> >>   ...
> >>  <div id="35" class="filmstrip-cell"
> >>   </div>
> >> </div>
> >>
> >>
> >> --
> >> If you ask me if it can be done. The answer is YES, it can always be
> >> done. The correct questions however are... What will it cost, and how
> >> long will it take?
> >
> >
> >
> > --
> > John Arrowwood
> > John (at) Irie (dash) Inc (dot) com
> > John (at) Arrowwood Photography (dot) com
> > John (at) Hanlons Razor (dot) com
> > --
> > http://www.irie-inc.com/
> > http://arrowwood.blogspot.com/
> >
>
>
>
> --
> If you ask me if it can be done. The answer is YES, it can always be
> done. The correct questions however are... What will it cost, and how
> long will it take?
>



-- 
John Arrowwood
John (at) Irie (dash) Inc (dot) com
John (at) Arrowwood Photography (dot) com
John (at) Hanlons Razor (dot) com
--
http://www.irie-inc.com/
http://arrowwood.blogspot.com/

Reply via email to