get value from input box and display in another input using jquery




// First way to get a value
value = $("#txt_name").val(); 

// Second way to get a value
value = $("#txt_name").attr('value');
If you want to use straight JavaScript to get the value, here is how:
document.getElementById('txt_name').value 


 so here it is


 <input id="totalsum" type="text" name="totalsum" value="<?php echo $total; ?>">
  <input id="totalsum1" type="text" name="totalsum" value="">

 <style>
 #totalsum {
    width: 110px;
    background-color: none;
    border:none;
}
</style>
<script type="text/javascript">
        $(document).ready(function() {
        $(':checkbox:checked').prop('checked',false);
    function updateSum() {
      var total = <?php echo $total; ?>;
      $(".sum:checked").each(function(i, n) {total += parseFloat($(n).val());})
      $("#totalsum").val(total.toFixed(2));
      getsum=document.getElementById('totalsum').value;
    document.getElementById('totalsum1').value =getsum;
    }
    // run the update on every checkbox change and on startup
    $("input.sum").change(updateSum);
    updateSum();
   
})
    </script>
<input name="addons1[]" class="sum" value="10.98"  type="checkbox"> Outside Wash
<br>

<input name="addons1[]"  class="sum" value="39.98"  type="checkbox"> A <br>

<input name="addons1[]"  class="sum" value="0" type="checkbox"> B <br>

<input name="addons1[]"  class="sum" value="109.78" type="checkbox"> C <br/> 

                <input id="totalasum" type="text"  value="">




Comments

Popular posts from this blog

Script For Login, Logout and View Using PHP, MySQL and Bootstrap

PHP Ajax Login Validation Tutorial

Insert CheckBox and Radio button Data in MySQL Database Using PHP