mardi 27 septembre 2016

Show Selected Multiple checkbox values as Text using jquery (Dynamic values)

Show Selected Multiple checkbox values as text. This not duplicate i have searched for it.

Dynamic Form values:

<div class="form-group">Eligible Branch
    <select id="eligiblebranch" multiple="multiple" class="form-control" >
        <?php  $branch = $conn->query("SELECT * FROM r_branch  ORDER BY id_branch ASC");
            while ($branchresult = $branch->fetch_assoc()) { ?>
            <option value="<?php echo $branchresult['id_branch']; ?>"> <?php echo $branchresult['branch_name']; ?> </option>
        <?php } ?>
    </select>
</div> 

Script:

var checked_checkboxes = $("[id*=eligiblebranch] input:checked");
var message = "";
checked_checkboxes.each(function () {
    var value = $(this).val();
    message += + value;
    message += "\n";
});
$("#eligiblebranch1").html(message);

Output should be Text and has to visible here:

<span id="eligiblebranch1"> </span>




Aucun commentaire:

Enregistrer un commentaire