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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:08:41+00:00 2026-05-13T00:08:41+00:00

What would be the best way to have preloaded data in html and then

  • 0

What would be the best way to have preloaded data in html and then used with javascript. I do not want to use variables in javascript or save an ajax query.

It may be an XML data into a hidden div? .

Example:

1; Europe
2; Latin America

------------------

2, 1, Argentina
2, 2; Brazil
2, 3, Chile
1, 4, France
1, 5, Spain
1, 6; Italy

He would have to load the data into a select depending on the country you select. are much data and need to be fast, I prefer to have it preloaded.

EDIT. Solution, based on the proposed solutions:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 
<title></title>
<script type="text/javascript">
$(function(){

    $_save_data = $("<div>");

    $("#xselect optgroup").appendTo($_save_data);

    $("#buttonAddA").click(function(){
        $("#xselect").empty();
        $_save_data.find("optgroup[id='a'] option").clone().appendTo("#xselect");
    });

    $("#buttonAddB").click(function(){
        $("#xselect").empty();
        $_save_data.find("optgroup[id='b'] option").clone().appendTo("#xselect");
    });

});
</script>
</head>
<body>
<button id="buttonAddA">Add A</button>
<button id="buttonAddB">Add B</button>
<select id="xselect">
    <optgroup id="a">
        <option>a1</option>
        <option>a2</option>
        <option>a3</option>
        <option>a4</option>
        <option>a5</option>
    </optgroup>
    <optgroup id="b">
        <option>b1</option>
        <option>b2</option>
        <option>b3</option>
        <option>b4</option>
        <option>b5</option>
    </optgroup>
    <optgroup id="c">
        <option>c1</option>
        <option>c2</option>
        <option>c3</option>
        <option>c4</option>
        <option>c5</option>
    </optgroup>
</select>
</body>
</html>
  • 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-13T00:08:41+00:00Added an answer on May 13, 2026 at 12:08 am

    I’ve done the opposite thing in my project – I loaded full select, and then saved it’s content with JavaScript and only inserted what I wanted. That way users without JavaScript (or users waiting for JavaScript to load) can use my form.

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

Sidebar

Related Questions

In general terms and pseudo-code, what would be the best way to have a
I want to make a code snippet database web application. Would the best way
What would be the best way to version a rails application? We want to
What would be the best way to have a phone number change across a
What would the best way of unpacking a python string into fields I have
In C++ what would be the best way to have an object that needs
What would be the best/quickest way to have a IDE-type setup when I have
What would be the best way to have a self updating (from SVN) Powershell
What would be the best way to have a single image which when you
What would be the best way to have a list of items with a

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.