{"id":375,"date":"2024-05-21T12:43:26","date_gmt":"2024-05-21T10:43:26","guid":{"rendered":"https:\/\/blog.sutilweb.eu\/?page_id=375"},"modified":"2024-05-21T12:43:26","modified_gmt":"2024-05-21T10:43:26","slug":"24-selects-radios-y-checkboxes","status":"publish","type":"page","link":"https:\/\/sutilweb.eu\/index.php\/lenguajes\/html5\/html5-practico\/24-selects-radios-y-checkboxes\/","title":{"rendered":"24. Selects, radios y checkboxes"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Nota:<\/strong> La mayor\u00eda de los formularios se controlan con <strong>Javascript.<\/strong><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">&lt;select&gt;<\/h2>\n\n\n\n<p>Vamos a ver un ejm para ver como funcionan estas <strong>etiquetas.<\/strong><\/p>\n\n\n\n<p><strong>Ejm<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"es\"&gt;\n&nbsp; &lt;head&gt;\n&nbsp; &nbsp; &lt;meta charset=\"UTF-8\" \/&gt;\n&nbsp; &nbsp; &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n&nbsp; &nbsp; &lt;title&gt;Formulario&lt;\/title&gt;\n&nbsp; &lt;\/head&gt;\n\n&nbsp; &lt;body&gt;\n&nbsp; &nbsp; &lt;h1&gt;Formulario&lt;\/h1&gt;\n\n&nbsp; &nbsp; &lt;select name=\"idioma\" id=\"\" required&gt;\n&nbsp; &nbsp; &nbsp; &lt;option value=\"\"&gt;--Elige una opci\u00f3n--&lt;\/option&gt;\n&nbsp; &nbsp; &nbsp; &lt;option value=\"en\"&gt;Ingl\u00e9s&lt;\/option&gt;\n&nbsp; &nbsp; &nbsp; &lt;option value=\"es\" selected&gt;Espa\u00f1ol&lt;\/option&gt;\n&nbsp; &nbsp; &nbsp; &lt;option value=\"fr\"&gt;Franc\u00e9s&lt;\/option&gt;\n&nbsp; &nbsp; &lt;\/select&gt;\n&nbsp; &nbsp; &lt;input type=\"submit\" \/&gt;&lt;input type=\"reset\" \/&gt;\n&nbsp; &lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Radio botones<\/h2>\n\n\n\n<p>Los <strong>radio botones<\/strong> sirven para que de diferentes opciones s\u00f3lo tengamos que seleccionar una. Veamos un ejm de su sintaxis.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Nota:<\/strong> muy importante, todas las opciones de este tipo de <strong>input<\/strong> tienen que tener el mismo nombre.<\/p>\n<\/blockquote>\n\n\n\n<p><strong>Ejm<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"es\"&gt;\n&nbsp; &lt;head&gt;\n&nbsp; &nbsp; &lt;meta charset=\"UTF-8\" \/&gt;\n&nbsp; &nbsp; &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n&nbsp; &nbsp; &lt;title&gt;Formulario&lt;\/title&gt;\n&nbsp; &lt;\/head&gt;\n\n&nbsp; &lt;body&gt;\n&nbsp; &nbsp; &lt;h1&gt;Formulario&lt;\/h1&gt;\n&nbsp; &nbsp; &lt;p&gt;Elige tu lenguaje de programaci\u00f3n favorito&lt;\/p&gt;\n\n&nbsp; &nbsp; &lt;input type=\"radio\" name=\"lenguaje\" id=\"radio-js\" value=\"js\" \/&gt;\n&nbsp; &nbsp; &lt;label for=\"radio-js\"&gt;Javascript&lt;\/label&gt;\n\n&nbsp; &nbsp; &lt;input type=\"radio\" name=\"lenguaje\" id=\"radio-py\" value=\"py\" \/&gt;\n&nbsp; &nbsp; &lt;label for=\"radio-py\"&gt;Python&lt;\/label&gt;\n\n&nbsp; &nbsp; &lt;input type=\"radio\" name=\"lenguaje\" id=\"radio-php\" value=\"php\" \/&gt;\n&nbsp; &nbsp; &lt;label for=\"radio-php\"&gt;PHP&lt;\/label&gt;\n\n&nbsp; &nbsp; &lt;input type=\"submit\" \/&gt;&lt;input type=\"reset\" \/&gt;\n&nbsp; &lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Nota:<\/strong> Al <strong>input radio<\/strong> que queremos que se cargue, le ponemos el atributo <strong><em>checked<\/em><\/strong>. Y si queremos que se env\u00ede este tipo de input, le ponemos el atributo <strong>required<\/strong> a cualquiera de las opciones de que disponemos, no hay porque pon\u00e9rselo a todas.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">&lt;checkbox&gt;<\/h2>\n\n\n\n<p>Son los tipos de inputs en que se puede seleccionar m\u00e1s de una opci\u00f3n. Veamos un ejm para ver su sintaxis.<\/p>\n\n\n\n<p><strong>Ejm<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"es\"&gt;\n&nbsp; &lt;head&gt;\n&nbsp; &nbsp; &lt;meta charset=\"UTF-8\" \/&gt;\n&nbsp; &nbsp; &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n&nbsp; &nbsp; &lt;title&gt;Formulario&lt;\/title&gt;\n&nbsp; &lt;\/head&gt;\n\n&nbsp; &lt;body&gt;\n&nbsp; &nbsp; &lt;h1&gt;Formulario&lt;\/h1&gt;\n&nbsp; &nbsp; &lt;p&gt;Elige tu lenguaje de programaci\u00f3n favorito&lt;\/p&gt;\n\n&nbsp; &nbsp; &lt;label&gt;\n&nbsp; &nbsp; &nbsp; &lt;input type=\"checkbox\" name=\"intereses\" value=\"Deportes\" \/&gt;\n&nbsp; &nbsp; &nbsp; Deportes\n&nbsp; &nbsp; &lt;\/label&gt;\n&nbsp; &nbsp; &lt;label&gt;\n&nbsp; &nbsp; &nbsp; &lt;input type=\"checkbox\" name=\"intereses\" value=\"Finanzas\" \/&gt;\n&nbsp; &nbsp; &nbsp; Finanzas\n&nbsp; &nbsp; &lt;\/label&gt;\n&nbsp; &nbsp; &lt;label&gt;\n&nbsp; &nbsp; &nbsp; &lt;input type=\"checkbox\" name=\"intereses\" value=\"Salud\" checked \/&gt; Salud\n&nbsp; &nbsp; &lt;\/label&gt;\n&nbsp; &nbsp; &lt;input type=\"submit\" \/&gt;&lt;input type=\"reset\" \/&gt;\n&nbsp; &lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Nota: La mayor\u00eda de los formularios se controlan con Javascript. &lt;select&gt; Vamos a ver un ejm para ver como funcionan [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":89,"menu_order":23,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-375","page","type-page","status-publish","hentry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Sutil Web","author_link":"https:\/\/sutilweb.eu\/index.php\/author\/sutilweb\/"},"uagb_comment_info":0,"uagb_excerpt":"Nota: La mayor\u00eda de los formularios se controlan con Javascript. &lt;select&gt; Vamos a ver un ejm para ver como funcionan [&hellip;]","_links":{"self":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/comments?post=375"}],"version-history":[{"count":2,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/375\/revisions"}],"predecessor-version":[{"id":377,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/375\/revisions\/377"}],"up":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/89"}],"wp:attachment":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/media?parent=375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}