jquery - Is there any to hide the radio buttons but not the drop down list? -
i have 2 radio buttons want hide , give drop down list users select from. possible hide radio buttons without hiding drop down list? $("[name^=useallcodes]").parent().hide(); hides dd list too.
<table> <tr> <td><input type="radio" name="useallcodes" value="yes" checked onclick="attreset();"> all<br> <input type="radio" name="useallcodes" value="no" onclick="attreset();" id="thesecodes"> these codes <br> <select name="handpick" onchange="atttoggleandreset();" size="10" multiple> <option value="25248692">code 1 <option value="25248693">code 2 </select> </td> </tr> </table>
if can't change original html, don't mind removing radio buttons, rather hiding them, following:
var $select = $("[name=handpick]"); var $cell = $select.parent(); $select.detach(); $cell.empty().append($select); this detaches select element, clears out table cell, , puts select element back.
if still need radio buttons process values, replace them hidden input.
var $radio = $('#thesecodes'); var radiovalue = $radio.val(); var radioname = $radio.attr('name'); var $cell = $radio.closest('td'); var $select = $cell.find('select'); $select.detach(); $cell.empty().append('<input type="hidden" name="' + radioname + '" value="' + radiovalue + '" />').append($select); if post form radio buttons hidden, value not included, value of hidden input be.
Comments
Post a Comment