Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8441413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:33:30+00:00 2026-06-10T08:33:30+00:00

i have this ajax setup that performs some php calculations when a user changes

  • 0

i have this ajax setup that performs some php calculations when a user changes the selection of a dropdown, it then sends back the results and outputs them. This all works fine except, when the user first loads the screen they are greeted, with just empty result boxes, and only when they change a selection in one of the dropdown boxes, do the results appear. My question is, is there anyway to run the ajax when the window is loaded, so the default dropdown selection can be ouputed.

Here is the ajax code, let me know if you need anything else:

  <script>
$("document").ready(function (){ 

    $(".add_detail_dropdown").change(function(){


        var m = document.getElementById('meter_square');
        var meter_square = m.options[m.selectedIndex].value;

        var s = document.getElementById('story_height');
        var story_height = s.options[s.selectedIndex].value;

        var r = document.getElementById('roof_type');
        var roof_type = r.options[r.selectedIndex].value;

        var q = document.getElementById('material_quality');
        var material_quality = q.options[q.selectedIndex].value;

        var w = document.getElementById('wall_type');
        var wall_type = w.options[w.selectedIndex].value;

        var f = document.getElementById('flooring');
        var flooring = f.options[f.selectedIndex].value;

     $.ajax({
            type: "GET",
            url: "add_extension_calc.php",
            data: { meter_square: meter_square, story_height: story_height, roof_type: roof_type, material_quality: material_quality, wall_type: wall_type, flooring: flooring, estimated_wealth: <?php print "$estimated_wealth";?>, gain_percent: <?php print "$addon_gain_percent";?>  },
            dataType: "json",
            statusCode: {
                200: function (response) {
                                            $("#res_expected_gain").html(response.total_gain);
                                            $("#res_expected_house_price").html(response.house_price);
                                            $("#res_total_supply_cost").html(response.store_price);
                                            $("#res_total_supply_time").html(response.store_time);
                                            $("#res_expected_profit").html(response.expected_profit);
                                         }

            }
        });
})
});
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:33:31+00:00Added an answer on June 10, 2026 at 8:33 am

    simply use change(), it will trigger your change ..

    <script>
        $("document").ready(function (){ 
    
            $(".add_detail_dropdown").change(function(){
                // ............
            });
    
            $(".add_detail_dropdown").change();
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have jQuery Ajax request that sends data to a PHP page that then
I have this code that works well: {livre:empty_name} $.ajax({ url: sent.php, type: post, dataType:
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html
I have this problem that my sites uses alot of ajax and when a
Here's the setup: I have some MVC Controllers that are intended to be consumed
I have this AJAX submission form written with the jQuery validation plugin. It all
I have this AJAX loader, created using CSS. And I m trying to increase
I have this AJAX code, but it doesn't seem to throw the 'alert' method.
I have this ajax ConfirmButtonExtender in my page with the ConfirmText set to a
I have this link @Ajax.ActionLink(comment, CreateDebateComment, new { id = Model.DebateID}, new AjaxOptions {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.