<?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: Javascript set selection in select element</title>
	<atom:link href="http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/</link>
	<description></description>
	<lastBuildDate>Tue, 10 Jan 2012 01:21:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Paul</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/comment-page-1/#comment-638276</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Mon, 14 Sep 2009 16:43:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comment-638276</guid>
		<description>Here&#039;s a generic function that doesn&#039;t use jquery in case anyone is looking for one.

function setSelect(id, val) {
	elem = document.getElementById(id);
	for(i = elem.length - 1; i &gt; 0; i--) {
		if(elem[i].value == val) {
			elem[i].selected = true;
			break;
		}
	}
}</description>
		<content:encoded><![CDATA[<p>Here&#039;s a generic function that doesn&#039;t use jquery in case anyone is looking for one.</p>
<p>function setSelect(id, val) {<br />
	elem = document.getElementById(id);<br />
	for(i = elem.length &#8211; 1; i &gt; 0; i&#8211;) {<br />
		if(elem[i].value == val) {<br />
			elem[i].selected = true;<br />
			break;<br />
		}<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jennifer</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/comment-page-1/#comment-636677</link>
		<dc:creator>Jennifer</dc:creator>
		<pubDate>Tue, 04 Aug 2009 19:06:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comment-636677</guid>
		<description>@Richard - your solution does work! Good to know I don&#039;t need to tack on the selectOptions plugin! Thanks!</description>
		<content:encoded><![CDATA[<p>@Richard &#8211; your solution does work! Good to know I don&#039;t need to tack on the selectOptions plugin! Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jennifer</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/comment-page-1/#comment-636676</link>
		<dc:creator>Jennifer</dc:creator>
		<pubDate>Tue, 04 Aug 2009 18:58:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comment-636676</guid>
		<description>@David - except that simply doing selectElement.value = &quot;myValue&quot; doesn&#039;t work (at least not in Firefox)... That would be nice, though, if it were that simple. :/</description>
		<content:encoded><![CDATA[<p>@David &#8211; except that simply doing selectElement.value = &#034;myValue&#034; doesn&#039;t work (at least not in Firefox)&#8230; That would be nice, though, if it were that simple. :/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rainabba</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/comment-page-1/#comment-636028</link>
		<dc:creator>rainabba</dc:creator>
		<pubDate>Fri, 17 Jul 2009 00:30:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comment-636028</guid>
		<description>David: That is freaking hilarious. All those amazingly complex solutions and the answer couldn&#039;t be more elegant :)</description>
		<content:encoded><![CDATA[<p>David: That is freaking hilarious. All those amazingly complex solutions and the answer couldn&#039;t be more elegant <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/comment-page-1/#comment-628557</link>
		<dc:creator>David</dc:creator>
		<pubDate>Sat, 11 Apr 2009 19:30:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comment-628557</guid>
		<description>Actually, if your have the id to your select object and you know what the values are, you can just set

selectElement.value = &quot;myValue&quot;

and it will select it properly.</description>
		<content:encoded><![CDATA[<p>Actually, if your have the id to your select object and you know what the values are, you can just set</p>
<p>selectElement.value = &#034;myValue&#034;</p>
<p>and it will select it properly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: link</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/comment-page-1/#comment-622328</link>
		<dc:creator>link</dc:creator>
		<pubDate>Thu, 19 Feb 2009 06:49:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comment-622328</guid>
		<description>http://javascript.internet.com/forms/select-value-set.html</description>
		<content:encoded><![CDATA[<p><a href="http://javascript.internet.com/forms/select-value-set.html" rel="nofollow">http://javascript.internet.com/forms/select-value-set.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/comment-page-1/#comment-621296</link>
		<dc:creator>Richard</dc:creator>
		<pubDate>Wed, 11 Feb 2009 14:16:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comment-621296</guid>
		<description>Just to let you know the selectOptions plugin is not necessary when using JQuery. You can use the following just as well:

$(document).ready(function() {
$(&quot;#selectboxname&quot;).val(&quot;The Select Value&quot;);
});

Thanks for the post though, pointed me in the right direction, and yeah JQuery does rule.</description>
		<content:encoded><![CDATA[<p>Just to let you know the selectOptions plugin is not necessary when using JQuery. You can use the following just as well:</p>
<p>$(document).ready(function() {<br />
$(&#034;#selectboxname&#034;).val(&#034;The Select Value&#034;);<br />
});</p>
<p>Thanks for the post though, pointed me in the right direction, and yeah JQuery does rule.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TK</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/comment-page-1/#comment-613692</link>
		<dc:creator>TK</dc:creator>
		<pubDate>Wed, 17 Dec 2008 00:58:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comment-613692</guid>
		<description>document.evaluate(&quot;//select[@id=&#039;selectboxname&#039;]//option[@value=&#039;The Selected Value&#039;, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).selected = true;</description>
		<content:encoded><![CDATA[<p>document.evaluate(&#034;//select[@id='selectboxname']//option[@value=&#039;The Selected Value&#039;, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).selected = true;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neuropsykopat</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/comment-page-1/#comment-606072</link>
		<dc:creator>Neuropsykopat</dc:creator>
		<pubDate>Sun, 02 Nov 2008 22:23:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comment-606072</guid>
		<description>put a break instruction in the if closure. It&#039;ll stop the investigations.

for
{
if(found)
{
...
break;
}
}</description>
		<content:encoded><![CDATA[<p>put a break instruction in the if closure. It&#039;ll stop the investigations.</p>
<p>for<br />
{<br />
if(found)<br />
{<br />
&#8230;<br />
break;<br />
}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jennifer</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/comment-page-1/#comment-594834</link>
		<dc:creator>Jennifer</dc:creator>
		<pubDate>Sun, 07 Sep 2008 05:45:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comment-594834</guid>
		<description>Before I go crazy another night trying to find this. Yes, this is much easier with jquery (isn&#039;t everything!) :D

Use this plugin:
http://www.texotela.co.uk/code/jquery/select/

And this code:
$(document).ready(function() {
$(&quot;#selectboxname&quot;).selectOptions(&quot;The Select Value&quot;, true);
});</description>
		<content:encoded><![CDATA[<p>Before I go crazy another night trying to find this. Yes, this is much easier with jquery (isn&#039;t everything!) <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Use this plugin:<br />
<a href="http://www.texotela.co.uk/code/jquery/select/" rel="nofollow">http://www.texotela.co.uk/code/jquery/select/</a></p>
<p>And this code:<br />
$(document).ready(function() {<br />
$(&#034;#selectboxname&#034;).selectOptions(&#034;The Select Value&#034;, true);<br />
});</p>
]]></content:encoded>
	</item>
</channel>
</rss>

