{"id":340,"date":"2010-02-26T17:22:58","date_gmt":"2010-02-26T20:22:58","guid":{"rendered":"http:\/\/stefano.salvatori.cl\/blog\/?p=340"},"modified":"2010-02-26T17:22:58","modified_gmt":"2010-02-26T20:22:58","slug":"enviar-datos-entre-dos-select-usando-jquery","status":"publish","type":"post","link":"https:\/\/stefano.salvatori.cl\/blog\/2010\/02\/26\/enviar-datos-entre-dos-select-usando-jquery\/","title":{"rendered":"Enviar datos entre dos select usando jQuery"},"content":{"rendered":"<p>Hoy me vi en la necesidad de implementar dos select los cuales se enviaban informaci\u00f3n entre ellos (los t\u00edpicos usados para seleccionar ciertos elementos de un conjunto). Encontre un plugin de jQuery muy \u00fatil (b\u00e1sicamente hace todo por nosotros).<\/p>\n<p>Se llama <a href=\"http:\/\/www.meadmiracle.com\/dlb\/DLBDocumentation.aspx\">Dual Listbox<\/a>, su utilizaci\u00f3n es la siguiente.<\/p>\n<p><code lang=\"javascript\"><br \/>\n$.configureBoxes({<br \/>\n   box1View:'PollIds',<br \/>\n   box2View:'PollId',<br \/>\n);<br \/>\n<\/code><\/p>\n<p>con <strong>box1View <\/strong>establecemos cual ser\u00e1 el select 1 y con <strong>box2View <\/strong>el select 2, existen muchas opciones todas documentadas en su p\u00e1gina web.<\/p>\n<p>Finalmente para enviar la informaci\u00f3n se debe usar un peque\u00f1o truco (gracias <a href=\"http:\/\/www.bilson.cl\" target=\"_blank\">Bilson<\/a>), el cual consiste en seleccionar todos elementos del select 2 utilizando javascript al enviar el formulario.<\/p>\n<p><code lang=\"html\"><br \/>\n<input onclick=\"selectAll('#nombreidselect2',true)\" type=\"submit\" value=\"Enviar\" \/><br \/>\n<\/code><\/p>\n<p><code lang=\"javascript\"><br \/>\nfunction selectAll(selectBox,selectAll) {<br \/>\n   \/\/ have we been passed an ID<br \/>\n   if (typeof selectBox == \"string\") {<br \/>\n    selectBox = document.getElementById(selectBox);<br \/>\n   }<br \/>\n   \/\/ is the select box a multiple select box?<br \/>\n   if (selectBox.type == \"select-multiple\") {<br \/>\n      for (var i = 0; i &lt; selectBox.options.length; i++) {<br \/>\n         selectBox.options[i].selected = selectAll;<br \/>\n      }<br \/>\n  }<br \/>\n}<br \/>\n<\/code><\/p>\n<p>La funci\u00f3n de Javascript fue extra\u00edda desde <a href=\"http:\/\/www.qodo.co.uk\/blog\/javascript-select-all-options-for-a-select-box\/\" target=\"_blank\">qodo.co.uk<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hoy me vi en la necesidad de implementar dos select los cuales se enviaban informaci\u00f3n entre ellos (los t\u00edpicos usados para seleccionar ciertos elementos de un conjunto). Encontre un plugin de jQuery muy \u00fatil (b\u00e1sicamente hace todo por nosotros). Se llama Dual Listbox, su utilizaci\u00f3n es la siguiente. $.configureBoxes({ box1View:&#8217;PollIds&#8217;, box2View:&#8217;PollId&#8217;, ); con box1View establecemos [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[128,26,5],"tags":[],"class_list":["post-340","post","type-post","status-publish","format-standard","hentry","category-jquery","category-tips","category-webdev"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p5Pxa3-5u","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/stefano.salvatori.cl\/blog\/wp-json\/wp\/v2\/posts\/340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stefano.salvatori.cl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stefano.salvatori.cl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stefano.salvatori.cl\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stefano.salvatori.cl\/blog\/wp-json\/wp\/v2\/comments?post=340"}],"version-history":[{"count":2,"href":"https:\/\/stefano.salvatori.cl\/blog\/wp-json\/wp\/v2\/posts\/340\/revisions"}],"predecessor-version":[{"id":342,"href":"https:\/\/stefano.salvatori.cl\/blog\/wp-json\/wp\/v2\/posts\/340\/revisions\/342"}],"wp:attachment":[{"href":"https:\/\/stefano.salvatori.cl\/blog\/wp-json\/wp\/v2\/media?parent=340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stefano.salvatori.cl\/blog\/wp-json\/wp\/v2\/categories?post=340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stefano.salvatori.cl\/blog\/wp-json\/wp\/v2\/tags?post=340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}