If I'm understanding what you're wanting to do, I think you can accomplish your objective with just one line of code. Add the following right after the line reading var div = document.createElement("div"); :
div.style.float='left'; Of course, if you have additional styles that you will want to apply to the results, you may want to change approaches just a bit to add a class to the div so that you can style it with CSS elsewhere in your document. In this case, you would use the following instead: div.className='myClassNameHere'; Then you could go back to your CSS and add something like this: .className{float:left;color:#ff0000;} And you would end up with divs that are floated to the left with red text in them. Hope that helps! Jeremy R. Geerdes Effective website design & development Des Moines, IA For more information or a project quote: http://jgeerdes.home.mchsi.com http://jgeerdes.blogspot.com http://jgeerdes.wordpress.com jgeer...@mchsi.com Unless otherwise noted, any price quotes contained within this communication are given in US dollars. If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! And check out my blog, Adventures in Web Development, at http://jgeerdes.blogspot.com ! On Nov 3, 2009, at 9:09 AM, Blatcho wrote: > > I've currently got a very simple page taking info from an RSS feed > (Reuters), using the pretty much stock code from the api playground. > What i would like to do is loop through the feed results and put each > item into it's own layer, with the layer style set to float:left, so i > end up with something like this... > > News feed item 1 News feed item 2 News feed item 3 News feed item 4 > etc > > I understand i'm creating the DIV element in javascript; how do i ask > the code to put the results into separate layers appended as above? Do > i need to create separate result containers for each news feed item? > Ideally i guess i want to be dynamically creating layers for each news > item and then styling them using CSS...? Thanks! > > <script type="text/javascript"> > /* > * How to see historical entries in a feed. Usually a feed only > returns x number > * of results, and you want more. Since the Google Feeds API > caches feeds, you can > * dig into the history of entries that it has cached. This, > paired with setNumEntries, > * allows you to get more entries than normally possible. > */ > > google.load("feeds", "1"); > > // Our callback function, for when a feed is loaded. > function feedLoaded(result) { > if (!result.error) { > // Grab the container we will put the results into > var container = document.getElementById("Result"); > container.innerHTML = ''; > > // Loop through the feeds, putting the titles onto the page. > // Check out the result object for a list of properties > returned in each entry. > // > http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON > > for (var i = 0; i < result.feed.entries.length; i++) { > var entry = result.feed.entries[i]; > var div = document.createElement("div"); > div.appendChild(document.createTextNode(entry.title)); > container.appendChild(div); > } > } > } > > function OnLoad() { > // Create a feed instance that will grab Digg's feed. > var feed = new google.feeds.Feed("http://mf.feeds.reuters.com/ > reuters/UKStocksAndSharesNews"); > > //feed.includeHistoricalEntries(); // tell the API we want to > have old entries too > feed.setNumEntries(2); // we want a maximum of 100 entries, if > they exist > > // Calling load sends the request off. It requires a callback > function. > feed.load(feedLoaded); > } > > google.setOnLoadCallback(OnLoad); > </script> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group. To post to this group, send email to google-ajax-search-api@googlegroups.com To unsubscribe from this group, send email to google-ajax-search-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-ajax-search-api?hl=en -~----------~----~----~----~------~----~------~--~---