<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: More jQuery Fun &#8211; Auto Populating a Select Box</title>
	<atom:link href="http://www.aknosis.com/2009/10/15/more-jquery-fun-auto-populating-a-select-box/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aknosis.com/2009/10/15/more-jquery-fun-auto-populating-a-select-box/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
	<description>Once you go Ak, you don&#039;t go back.</description>
	<lastBuildDate>Fri, 18 Dec 2009 05:10:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Aknosis</title>
		<link>http://www.aknosis.com/2009/10/15/more-jquery-fun-auto-populating-a-select-box/comment-page-1/#comment-35</link>
		<dc:creator>Aknosis</dc:creator>
		<pubDate>Wed, 16 Dec 2009 07:13:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.aknosis.com/?p=185#comment-35</guid>
		<description>Thanks.

It wouldn&#039;t be to difficult to do. 

1. Setup your function that adds the options
2. Set the interval to call that function every 3 seconds

There is no real way to save the options other than a cookie, you could also look into some sort of hash magic but that becomes difficult to work cross browser (see jquery history plugin). 

I also can&#039;t seemt to find an easy way to serialize the options into text for storage in a cookie, so you probably would want to append to your cookie as you add each item. You will want to use common functions to turn your Objects in JSON and vice versca, (search for toJson).

So you really want something like this:
&lt;pre class=&quot;brush: jscript;&quot;&gt;
function updateOptions(){
   //This would be your dynamic call, probably ajax request
   var newOption = new Option(&#039;name&#039;, &#039;value&#039;);
   var s = $(&#039;#select&#039;)[0];
   var l = s.length;
   s[l] = newOption;
   //some predefined method to get the cookie
   //and convert it back into an object
   var cookie = eval(&#039;(&#039;+getCookie(&#039;optionSvr&#039;)+&#039;)&#039;);
  //add new option
   cookie.push(newOption);
   setCookie(&#039;optionSvr&#039;,toJSON(cookie));
}
//Run every 3 seconds
setInterval(&#039;updateOptions()&#039;,3000);
&lt;/pre&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function updateOptions(){
   var x = new Date().getTime();
   var newOption = new Option(x, x);
   var s = $(&#039;#selectCmt&#039;)[0];
   var l = s.length;
   s[l] = newOption;
   }
&lt;/script&gt;
Example (minus the cookie stuff)
&lt;input class=&quot;button&quot; value=&quot;test&quot; type=&quot;button&quot; onclick=&quot;setInterval(&#039;updateOptions()&#039;,3000);&quot; /&gt;
&lt;select id=&quot;selectCmt&quot;&gt;&lt;/select&gt;</description>
		<content:encoded><![CDATA[<p>Thanks.</p>
<p>It wouldn&#8217;t be to difficult to do. </p>
<p>1. Setup your function that adds the options<br />
2. Set the interval to call that function every 3 seconds</p>
<p>There is no real way to save the options other than a cookie, you could also look into some sort of hash magic but that becomes difficult to work cross browser (see jquery history plugin). </p>
<p>I also can&#8217;t seemt to find an easy way to serialize the options into text for storage in a cookie, so you probably would want to append to your cookie as you add each item. You will want to use common functions to turn your Objects in JSON and vice versca, (search for toJson).</p>
<p>So you really want something like this:</p>
<pre class="brush: jscript;">
function updateOptions(){
   //This would be your dynamic call, probably ajax request
   var newOption = new Option('name', 'value');
   var s = $('#select')[0];
   var l = s.length;
   s[l] = newOption;
   //some predefined method to get the cookie
   //and convert it back into an object
   var cookie = eval('('+getCookie('optionSvr')+')');
  //add new option
   cookie.push(newOption);
   setCookie('optionSvr',toJSON(cookie));
}
//Run every 3 seconds
setInterval('updateOptions()',3000);
</pre>
<p><script type="text/javascript">
function updateOptions(){
   var x = new Date().getTime();
   var newOption = new Option(x, x);
   var s = $('#selectCmt')[0];
   var l = s.length;
   s[l] = newOption;
   }
</script><br />
Example (minus the cookie stuff)</p>
<input class="button" value="test" type="button" onclick="setInterval('updateOptions()',3000);" />
<select id="selectCmt"></select>
]]></content:encoded>
	</item>
	<item>
		<title>By: zkilz</title>
		<link>http://www.aknosis.com/2009/10/15/more-jquery-fun-auto-populating-a-select-box/comment-page-1/#comment-34</link>
		<dc:creator>zkilz</dc:creator>
		<pubDate>Tue, 15 Dec 2009 15:52:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.aknosis.com/?p=185#comment-34</guid>
		<description>Hi! 
Nice website. Im trying to create a dynamically select form that adds options from different variables automatically every 3 second. This will constantly go in a loop.

Is this something i can use to do that?
Do you know if there is any way to save the options so it doesn&#039;t go blank on reload of the page?

Thank you any answer.</description>
		<content:encoded><![CDATA[<p>Hi!<br />
Nice website. Im trying to create a dynamically select form that adds options from different variables automatically every 3 second. This will constantly go in a loop.</p>
<p>Is this something i can use to do that?<br />
Do you know if there is any way to save the options so it doesn&#8217;t go blank on reload of the page?</p>
<p>Thank you any answer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aknosis</title>
		<link>http://www.aknosis.com/2009/10/15/more-jquery-fun-auto-populating-a-select-box/comment-page-1/#comment-33</link>
		<dc:creator>Aknosis</dc:creator>
		<pubDate>Sat, 31 Oct 2009 06:58:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.aknosis.com/?p=185#comment-33</guid>
		<description>To sidestep my $(selector)[0].length = 0 to empty the select you can also do $(selector).empty();</description>
		<content:encoded><![CDATA[<p>To sidestep my $(selector)[0].length = 0 to empty the select you can also do $(selector).empty();</p>
]]></content:encoded>
	</item>
</channel>
</rss>
