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 6823269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:45:46+00:00 2026-05-26T21:45:46+00:00

Hi could someone help me out with this jQuery? I have: $(document).ready(function () {

  • 0

Hi could someone help me out with this jQuery? I have:

$(document).ready(function () {

    window.refresh = function () { setorganisationddl; }

    var setorganisationddl = function () {
        if ($("#Invoice_AreaId option:selected").val() == "") {
            $("#Invoice_OrganisationId > option").remove();
            $("#Invoice_OrganisationId").append($("<option value=''>-- Select --</option>"));
            $("#Invoice_OrganisationId").attr("disabled", "disabled");
        }
        else {
            $.get('/Invoice/GetOrganisationSelectList/' + $("#Invoice_AreaId option:selected").val(), function (response) {
                $("#Invoice_OrganisationId").removeAttr("disabled");

                var organisations = $.parseJSON(response);

                var ddlOrganisations = $("#Invoice_OrganisationId");

                $("#Invoice_OrganisationId > option").remove();

                for (i = 0; i < organisations.length; i++) {

                    if (organisations[i].Value == $("#Invoice_OrganisationId option:selected").val()) {
                        ddlOrganisations.append($("<option selected='selected' />").val(organisations[i].Value).text(organisations[i].Text));
                    }
                    else {
                        ddlOrganisations.append($("<option />").val(organisations[i].Value).text(organisations[i].Text));
                    }
                }
            });
        }
    }

    $("#Invoice_AreaId").change(setorganisationddl);
});

So I have setorganisationddl being called when ddl with id Invoice_AreaId is changed. Great. However I also want it called when the page loaded.

As you can see I tried:

window.refresh = function () { setorganisationddl; }

which doesn’t work.

  • 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-05-26T21:45:47+00:00Added an answer on May 26, 2026 at 9:45 pm

    you just need to re-arrange your code a bit.

    put a call to setorganisationddl in your document ready, and in the .change handler.

    $(document).ready(function () {
    
        setorganisationddl();
    
    
    
        $("#Invoice_AreaId").change(function(){
             setorganisationddl();
        });
    });
    
    function setorganisationddl() {
        if ($("#Invoice_AreaId option:selected").val() == "") {
            $("#Invoice_OrganisationId > option").remove();
            $("#Invoice_OrganisationId").append($("<option value=''>-- Select --</option>"));
            $("#Invoice_OrganisationId").attr("disabled", "disabled");
        }
        else {
            $.get('/Invoice/GetOrganisationSelectList/' + $("#Invoice_AreaId option:selected").val(), function (response) {
                $("#Invoice_OrganisationId").removeAttr("disabled");
    
                var organisations = $.parseJSON(response);
    
                var ddlOrganisations = $("#Invoice_OrganisationId");
    
                $("#Invoice_OrganisationId > option").remove();
    
                for (i = 0; i < organisations.length; i++) {
    
                    if (organisations[i].Value == $("#Invoice_OrganisationId option:selected").val()) {
                        ddlOrganisations.append($("<option selected='selected' />").val(organisations[i].Value).text(organisations[i].Text));
                    }
                    else {
                        ddlOrganisations.append($("<option />").val(organisations[i].Value).text(organisations[i].Text));
                    }
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone help me out with this JQuery? I have a bunch of list
Could someone help me on this, I have created simple web services using axis2
I was hoping someone could help me out with this stupid problem I'm having
I wonder if someone could help me figure out how to parse a string
could someone help me on this problem, i want to access facebook API through
Could someone please help explain why I can't get this to work? I properly
I hope someone could help me on this. I want to add a month
could someone help me. I'm new to gwt and maybe this is so simple.
could someone please help me out with the (simplified) code below. I'm trying to
could someone help me to figure out if it is possible to take part

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.