I am trying to make a modal dialog with images where you can select multiple images. I need to get the values from the input and then delete it, but I cannot clear the input. I tried .val('') and .val(null) but didn't work for me.
Here is the complete code:
$("#hdselect").click(function(){ $(".modal").html(""); $.post('mediaservice.php',{hd:'ok',images:$("#hdimages").val()},function(data){ $(".modal").append(data); }); $(".modal").dialog({ 'modal':true, 'title':"Click the image to select", 'width':960, 'height':600, 'resizable':false, 'show': {effect: 'drop', direction: "up"}, 'buttons': {"Ok": function() { var hd=Array(); var hdval=$("#hdimages").val(); $("#hdimages").attr('value',' '); $("input[name='hd[]']:checked").each(function(){ hd.push($(this).val()); }); if(hdval!=''){ hdval=hdval+","+hd; }else{ hdval=hd; } $("#hdimages").val(hdval); var images=$("#hdimages").val(); $.post('mediaservice.php',{getHd:images},function(data){ $("#imgthumbBase").append(data); }); $(this).dialog("close"); } } }); });
The idea is that the user presses a button and a modal dialog box opens with several images and check boxes. At this point, I need to get the values from the input, and then clear it.
javascript jquery html jquery-ui
Vit Kos May 25 '12 at 12:59 a.m. 2012-05-25 12:59
source share