<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>devexp &#187; element</title>
	<atom:link href="http://www.devexp.eu/tag/element/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devexp.eu</link>
	<description>DEVelopment EXPerience, shared with the world!</description>
	<lastBuildDate>Fri, 28 Oct 2011 12:07:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Select element, return 2 values</title>
		<link>http://www.devexp.eu/2009/01/30/select-element-return-2-values/</link>
		<comments>http://www.devexp.eu/2009/01/30/select-element-return-2-values/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 10:53:22 +0000</pubDate>
		<dc:creator>van Rumste Kenneth</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[Jquery]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[option]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[values]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=340</guid>
		<description><![CDATA[I had a problem earlier today: I needed to have a select box that returns 2 or more values in stead of 1. I got this far: The value of the options gets the id of the item that is &#8230; <a href="http://www.devexp.eu/2009/01/30/select-element-return-2-values/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I had a problem earlier today: I needed to have a select box that returns 2 or more values in stead of 1.<br />
I got this far:<br />
The value of the options gets the id of the item that is displayed in each option.<br />
I do have an other value that should be linked on this option. Is there an easy way to do this?</p>
<pre class="brush: xml; title: ; notranslate">
&lt;select id=&quot;category&quot; name=&quot;data[cat]&quot;&gt;
    &lt;option label=&quot;0&quot; value=&quot;12&quot;&gt;A&lt;/option&gt;
    &lt;option label=&quot;0&quot; value=&quot;7&quot;&gt;B&lt;/option&gt;
&lt;/select&gt;
</pre>
<p>I tried to do this with entering the second value into a label attribute but then the problem is that i don&#8217;t know the correct way to get the label value of the selected option. This is written in Jquery.<br /> To get the selected option I use:</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;#category&quot;).livequery('change', function () {
var catId = ($(this)[0].value);
});
</pre>
<p>the solution seems to be quite simple:</p>
<p>The label attribute is used by some browsers to display the content of the option, so your list box might display two 0 options.</p>
<p>A better solution might be to do the following:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;select id=&quot;category&quot; name=&quot;data[cat]&quot;&gt;
    &lt;option value=&quot;12,0&quot;&gt;A&lt;/option&gt;
    &lt;option value=&quot;7,0&quot;&gt;B&lt;/option&gt;
&lt;/select&gt;
</pre>
<p>and split the value in the event handler, e.g.</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;#category&quot;).livequery('change', function () {
    var values = ($(this)[0].value).split(&quot;,&quot;);
    var catId = values[0];
    var otherId = values[1];
});
</pre>
<p>Wasn&#8217;t that easy</p>
<div class="shr-publisher-340"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/01/30/select-element-return-2-values/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

