{"id":6659,"date":"2020-06-26T12:55:46","date_gmt":"2020-06-26T17:55:46","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=6659"},"modified":"2020-06-26T12:55:47","modified_gmt":"2020-06-26T17:55:47","slug":"html-multiple-values-on-select-option","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=6659","title":{"rendered":"HTML &#8211; Multiple Values on Select Option"},"content":{"rendered":"\n<p>I needed to pass multiple values with a select option. It&#8217;s easily accomplished by setting the value to a JSON string<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\nwhile ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {\n\techo &quot;&lt;option value= &quot; . json_encode($row) . &quot;&gt;&quot; . $row&#x5B;&#039;STRTYPENAME&#039;] . &quot;&lt;\/option&gt;\\n&quot;;\n}\n\n<\/pre><\/div>\n\n\n<p>And using JSON.parse to pull out the key of the value you need:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\njQuery(&quot;#selectDivSetType&quot;).change(function () {     \n    var strTemplateObject = $(&#039;#selectDivSetType&#039;).val();\n    var jsonTemplateObject = JSON.parse( strTemplateObject );\n    var strTemplateURI = &#039;.\/templates\/&#039; + jsonTemplateObject.STRTEMPLATENAME;\n    $(&#039;#templateURI&#039;).attr(&quot;href&quot;, strTemplateURI); \n});\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>I needed to pass multiple values with a select option. It&#8217;s easily accomplished by setting the value to a JSON string And using JSON.parse to pull out the key of the value you need:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[765,1037,854],"class_list":["post-6659","post","type-post","status-publish","format-standard","hentry","category-coding","tag-html","tag-html-forms","tag-jquery"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6659"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6659\/revisions"}],"predecessor-version":[{"id":6660,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6659\/revisions\/6660"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}