below code. want the value of submit button in ajax part not able that. please tell me how value of button.
<script src="http://localhost/ci/js/jquery.js"></script> <script type="text/javascript"> // ajax post $(document).ready(function() { $('#f input').on('change', function() { //alert("hio"); var b = $('input[name="r5"]:checked', '#f').val(); //alert(b); $("#h1").val(b); }); $(".submit").click(function(event) { event.preventdefault(); var ans = $("input#h1").val(); var que = $("input#h").val(); var no = $("input#h2").val(); var de = $("input.submit").val(); jquery.ajax({ type: "post", url: "http://localhost/ci/index.php/controller_q/quchng", datatype: 'json', data: { ans: ans, que: que, no: no, de: de }, success: function(res) { jquery('#i').html(res); } }); }); }); </script> this view page code:
<div id="i"> <?php $a = 1; ?> time left- <span id="countdown" class="timer"></span> q: <?php echo $qno['ques'.$a];?> <form id="f"> <input type="radio" name="r5" id="r1" value="<?php echo $qno['a'.$a];?>"><?php echo $qno['a'.$a];?><br> <input type="radio" name="r5" id="r2" value="<?php echo $qno['b'.$a];?>"><?php echo $qno['b'.$a];?><br> <input type="radio" name="r5" id="r3" value="<?php echo $qno['c'.$a];?>"><?php echo $qno['c'.$a];?><br> <input type="radio" name="r5" id="r4" value="<?php echo $qno['d'.$a];?>"><?php echo $qno['d'.$a];?><br> <button id="b" class="submit" value='po'>save & next</button> <button id="b" class="submit" value='po'>save next</button> <input type="hidden" id="h" value="<?php print_r($qno);?>"> <input type="hidden" id="h1"> <input type="hidden" id="h2" value="<?php echo $a;?>"> </form> </div>
this because doing wrongly:-
$(".submit").click(function(event) { var de = $(this).val(); // check button clicked , button value alert(de);return false; // check value coming or not. check , value.thanks.
Comments
Post a Comment