Se non avete accesso all’html di un CMS e volete cambiare una textbox in una checkbox, ecco il codice jQuery che ve lo fa fare!
Enjoy!!!
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.2.min.js"></script> <script src="https://code.jquery.com/jquery-migrate-1.2.1.js"></script> </head> <body> <select size="1" name="mySelect" id="mySelect"> <option selected="selected" value="Any">Hello</option> <option value="1">Questo è una</option> <option value="2">Textbox</option> <option value="3">In realtà :O)</option> </select> </body> </html> <script type="text/javascript"> $(function(){ //$(".main_container select").selectbox(); $('select').each(function(i, select){ var $select = $(select); $select.find('option').each(function(j, option){ var $option = $(option); // Create a radio: var $radio = $('<input type="radio" />'); // Set name and value: $radio.attr('name', $select.attr('name')).attr('value', $option.val()); // Set checked if the option was selected if ($option.attr('selected')) $radio.attr('checked', 'checked'); // Insert radio before select box: $select.before($radio); //wrap radio in div $radio.wrap( "<div class='radio_button'></div>" ); // Insert a label: $radio.after( $("<label />").text($option.text()) ); // Insert a <br />: //$select.before("<br/>"); }); $select.remove(); }); }) </script>
Salvatelo come file Html e provatelo 😉