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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:54:49+00:00 2026-06-16T01:54:49+00:00

I try to load in content to a div in Intex based on choice

  • 0

I try to load in content to a div in Intex based on choice in a select box. It dont work so something is wrong. I made an example of four pages to show basicly how it is:

Index.html
one.html
two.html
three.html

In Index I have a select element with ID “selectchoice”:

<select id="selectchoice>
<option>Select a choice</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>

I also have a div in Index with id “get_content”:

<div id="get_content"></div>

When I change the select element to option 1 or 2 or 3 I want to load one.html or two.html or three.html into the div get_content.

Then I place this code in the header if Index.html, after the jQuery-file link.

<script>
$("#selectchoice").change(function(){
    $("#get_content").load("");
    $("#get_content").load("one.html");
    $("#get_content").load("two.html");
    $("#get_content").load("three.html");
});

And then I run the site (on a server with other load-scripts thats works on the same site), but its not working. What is wrong? :/

Kinda new to scrips and programming so do not be suprised if there is any standard error.

Anybody finding the error?

  • 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-16T01:54:49+00:00Added an answer on June 16, 2026 at 1:54 am

    Your select tag is not closed properly. Add " after your id to close the id attribute.
    It’ll then look like this:

    <select id="selectchoice"> …

    Try replacing your javascript with this:

    $(document).ready(function (){
        $("#selectchoice").change(function(){
    
            var selectedOption = $('#selectchoice :selected').val();
            $containerDiv = $('#get_content');
            $containerDiv.html("");
    
            switch (selectedOption)
            {
                case "1": 
                    $containerDiv.load( "one.html" );
                    break;
    
                case "2":
                    $containerDiv.load( "two.html" );
                    break;
    
                case "3":
                    $containerDiv.load( "three.html" );
                    break;
    
                default:
                    $containerDiv.load( "whatever.html" );
                    break;
           }
    
            return true;
        });​
    });
    

    $(document).ready(...) makes the code execute once the page is loaded, which means it’ll bind the function to the onChange event right when you will load the page, while before it wouldn’t execute the script since it wasn’t called anywhere.

    This code respects most of the Object Calisthenics practices. I cut myself some loose since it is only a small snippet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the ajax to load a div content, but the div content is
Let's say I use jQuery to load new content into a specific DIV element.
Why I try to load a fancybox, the content isn't loaded. The problem only
I try to load a file using AJAX, which does NOT work. View @{
I try to load the customview class that is inside my mainclass in xml.
I try to load data into a certain column into a table with the
I try to load a node only to face the EInvalidPointer error on Delphi.
I try to load files in different categories according to theis file name. Till
I was try to load unlimited categories to dropdownlist but I failed. **Categories** ID,
When I try to load the following page in IE7 & IE8 I receive

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.