vendredi 28 septembre 2018

How to sum the selected values from the radio button and pass to submit

I need the sum the values from the selected radio button and add to the submit button.

Find the code below :

 <?php foreach($configure['options']['option'] as $options)
  {
  ?>

<label class="containerRadio">
<input type="radio" class="calc" name="" value=" 
 _-- 
 " checked="checked">
 <span class="checkmark"></span>
 </label>

 <?php } ?> </div><br><br> <?php } ?><input type="text" name="sum"></button>
 <button type="submit" name="sum"><i class="fa fa-rupee" aria-hidden="true"> 
 </i> 
 </button>

Fimd below the javascript :

            <script type="text/javascript">
function calcscore(){
var score = 0;
$(".calc:checked").each(function(){
    score+=parseInt($(this).val(),10);
});
$("input[name=sum]").val(score)
}
$().ready(function(){
$(".calc").change(function(){
    calcscore()
});
});
</script>

Suggest a solution to add the value selected from the radio button to the default value given as "".



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2OkZlKI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire