Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

JavaScript Is JSON the solution?

This is the calculated form I am trying to make: https://vadisabilitygroup.com/va-disability-retro-back-pay-calculator/

What process should I use to allow this calculator to process?

The first question is the date the Veteran filed their claim minus the date they are using this calculator. The answer I want is the number of months between the two dates.

Next, they will choose the percentage they should have been rated, but this starts my confusion. Each percentage has a value to it. For example 10% is $152.64, 20% is $301.74 and so on. But because these percentages are linked to dollar amounts that change every year they are not actually taking 10% of a whole number. So I would need to store the dollar amounts somewhere else?

each question will build on itself. So if the Veteran has a 30% rating, and they have a spouse and they have 4 children, each of these variables adds more to their ending total.
As you can see below there are no $ values connected to these options. And also the JQuery section of the calculator I am trying to create on my own, I am just trying to figure out where the values are stored, what the values look like, and how to create my own JSON file if that is even what I need to do.

Code:
    <div class="col-md-12">
            <label for ="newBenefitRate">What was the benefit rate VA should have been paying you on this date?</label>
            <span class="jcf-select-retro-select jcf-select-newBenefitRate">
            <select class="retro-select form-control newBenefitRate" id= "newBenefitRate">
                <option value select>Select an Option</option>
                <option value="10">10%</option>
                <option value="20">20%</option>
                <option value="30">30%</option>
                <option value="40">40%</option>
                <option value="50">50%</option>
                <option value="60">60%</option>
                <option value="70">70%</option>
                <option value="80">80%</option>
                <option value="90">90%</option>
                <option value="100">100%</option>
            </select>
        </span>
        </div>


Code:
    <script>
        
        jQuery(document).ready(function() {
                jQuery('.tooltip').tooltipster({
                    contentAsHTML:true
                });
            });
    //     jQuery(document).on('click','.add-more-row',function() {
    //         var $el = jQuery('.retro_calculator_content').clone();
    //         $el.find("input:text").val("");
    // $el.find(".remove_retro_calculator_content").html('<a class="remove-row" href="javascript:void(0)">Remove</a>');
    //             jQuery('.retro_calculator_content_rows').append($el);
    //     });
        
        
    jQuery(document).ready(function() {
        
    setTimeout(function(){   
    jQuery('select').removeClass('jcf-reset-appearance');
    jQuery('select').attr('style', '');

    jQuery('span').removeClass('jcf-select');
    jQuery('span').removeClass('jcf-unselectable');
    jQuery('span').removeClass('jcf-select-form-control');

    jQuery('span.jcf-select-text').remove();
    jQuery('span.jcf-select-opener').remove();

    }, 100);

    });
    var i = 1;
    jQuery(document).on('click','.add-more',function(){
        var retro_calculator_content = jQuery(".retro_calculator_content:last").clone();
        jQuery(".retro_calculator_content:last").find('select').each(function(i) {
            retro_calculator_content.find('select').eq(i).val(jQuery(this).val())
        })
        retro_calculator_content.find('.startDateMonth').val('');
        retro_calculator_content.find('.startDateYear').val('');
        //retro_calculator_content.find("input:text").val("");
        //retro_calculator_content.find(".stop_date").attr("name","stop_date_"+i);
        //retro_calculator_content.find('.stop-date-no').prop('checked', true);
        //retro_calculator_content.find('.single-status').prop('checked', true);
        //retro_calculator_content.find('.spouse_option').prop('checked', false);
        //retro_calculator_content.find('.spouse').hide();
        //retro_calculator_content.find('.stop_date_question').hide();
        retro_calculator_content.find(".marital_status").attr("name","marital_"+i);
        retro_calculator_content.find(".spouse_option").attr("name","maritalAA_"+i);
        retro_calculator_content.find('.remove_retro_calculator_content').html('<a class="remove-row" href="javascript:void(0)">Remove</a>');
        jQuery('.retro_calculator_content_rows').append(retro_calculator_content);
        i = i+1;
    })
        
        jQuery(document).on('click','#reset',function(){
        jQuery('.retro_calculator_content:not(:first)').remove();
        jQuery('.startDateMonth').val('');
        jQuery('.startDateYear').val('');
        jQuery('.newBenefitRate').val('');
        jQuery('.priorBenefitRate').val('');
        jQuery('.dependentParents').val('');
        jQuery('.childrenUnder18').val('');
        jQuery('.childrenOver18').val('');
        jQuery('.single-status').prop('checked', true);
        jQuery('.spouse_option').prop('checked', false);
        jQuery('.spouse').hide();
        jQuery('.stop_date_question').hide();
        jQuery('#reset_modal').modal('hide');
            jQuery('.result_div').html('');
            
            jQuery('html, body').animate({
            scrollTop: $("#retro_calculator").offset().top
        }, 500);
            
    });

    jQuery(document).on('click','.remove-row',function(){
        jQuery(this).closest('.retro_calculator_content').remove();
    });

        jQuery(document).ready(function(){
            
             jQuery(document).on('click',".marital_status",function(){
                var clst = jQuery(this).closest('.retro_calculator_content');
                var radioValue = clst.find(".marital_status:checked").val();
                if(radioValue == 1){
                    clst.find('.spouse').show();
                }
                else {
                    clst.find('.spouse').hide();
                    clst.find('.spouse_option').prop('checked', false);

                }
            });
            
            jQuery("#submitBtn").click(function(){
                var startDateMonthArray   = [];
                var startDateYearArray    = [];
                var newBenefitRateArray   = [];
                var priorBenefitRateArray = [];
                var marital_statusArray   = [];
                var spouse_optionArray    = [];
                var dependentParentsArray = [];
                var childrenUnder18Array  = [];
                var childrenOver18Array   = [];
                
                jQuery( ".retro_calculator_content" ).each(function() {
                    var startDateMonth   = jQuery(this).find('.startDateMonth').val();
                    var startDateYear    = jQuery(this).find('.startDateYear').val();
                    var newBenefitRate   = jQuery(this).find('.newBenefitRate').val();
                    var priorBenefitRate = jQuery(this).find('.priorBenefitRate').val();
                    var marital_status   = jQuery(this).find('.marital_status:checked').val();
                    var spouse_option    = jQuery(this).find('.spouse_option:checked').val();
                    var dependentParents = jQuery(this).find('.dependentParents').val();
                    var childrenUnder18  = jQuery(this).find('.childrenUnder18').val();
                    var childrenOver18   = jQuery(this).find('.childrenOver18').val();
                    
                    startDateMonthArray.push(startDateMonth);
                    startDateYearArray.push(startDateYear);
                    newBenefitRateArray.push(newBenefitRate);
                    priorBenefitRateArray.push(priorBenefitRate);
                    marital_statusArray.push(marital_status);
                    spouse_optionArray.push(spouse_option);
                    dependentParentsArray.push(dependentParents);
                    childrenUnder18Array.push(childrenUnder18);
                    childrenOver18Array.push(childrenOver18);
                });
                var formData          = {
                    startDateMonth: startDateMonthArray,
                    startDateYear: startDateYearArray,
                    newBenefitRate: newBenefitRateArray,
                    priorBenefitRate: priorBenefitRateArray,
                    marital_status: marital_statusArray,
                    spouse_option: spouse_optionArray,
                    dependentParents: dependentParentsArray,
                    childrenUnder18: childrenUnder18Array,
                    childrenOver18: childrenOver18Array
                };
                jQuery.ajax({
                    type: "POST",
                    url: '/ajax.php',
                    data: formData,
                    dataType:'json',
                    success: function(data)
                    {
                        jQuery('.result_div').html(data);
                    }
                });


});
});
</script>

<!-- end snippet -->
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom