html - How to display the checkbox value on same page without submit button and form in php? -
i have checkbox , if user selects check box value of checkbox display on same page without refresh page.
index.php
<input type="checkbox" value="<?php echo $value;?>" name="value_r" id="value_r"/> if(!isset($_post['value_r'])) echo $_post['value_r']; }
if ajax can 1 know how display value ajax?
$("#value_r").change(function () { var ischecked = $(this).is(":checked") ? 1:0; $.ajax({ type: "post", url: "index.php", async: true, data: { ischecked: ischecked }, success: function (response) { } }); });
instead of using ajax
or javascript
can using css
. check updated snippet below..
input[type=checkbox] + label{ display: none; } input[type=checkbox]:checked + label{ display: inline-block; }
<input type="checkbox" value="<?php echo $value;?>" name="value_r" id="value_r"/><label for="">checkbox value comes here</label>
wiki
Comments
Post a Comment