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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:41:26+00:00 2026-05-16T08:41:26+00:00

I have the following code which loads a xml file to populate a dropdown.

  • 0

I have the following code which loads a xml file to populate a dropdown. I would like to put the selected options text into a variable. I already got the value of the selection but not the text.

<!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 http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="all" href="style.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $.ajax({
    type: "GET",
    url: "make10.xml",
    dataType: "xml",
    success: function(xml) {
    var select = $('#mySelect');

var optionsHtml = new Array();
$('make', xml).each(function(){
              var value = $(this).attr('value');
              var label = $(this).text();
optionsHtml.push( "<option class='ddindent' value='"+ value +"'>"+label+"</option>");

    });
    optionsHtml = optionsHtml.join('');
select.append(optionsHtml);

select.children(":first").text("Select Make").attr("selected",true);

} 
}); 

$('#mySelect').change(function() {
var val=$(this).val();
alert(val);
});


}); 
</script>
</head>
<body>
<div id="page-wrap">
<select id="mySelect">
<option>loading</option>
</select>
</div>
</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-16T08:41:27+00:00Added an answer on May 16, 2026 at 8:41 am

    To get the text of the selected <option> you could use :selected and .text(), like this:

    $("#mySelect :selected").text();
    

    (Note the space, it’s a child so it’s important)

    Or, inside your current .change() handler it would look like this:

    $(this).children(":selected").text();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which loads and html file into a webview -
I have following piece of code which tries to load an XML file from
I have a xml file which I modify with the following code: XmlDocument xlDoc
I have the following code which I use to load the xml object but
Say I have an XML file like the following: <holidays> <holiday1 val=New Years, 01/01,
I have some code which fetches an XML file from a URL and then
I have an XML-File, which has the following structure: <mediawiki ...> <siteinfo>...</siteinfo> <page> <title>The
Hi i have the following code to read the xml file and change the
I have the following code, which I want to load values on a selection
I have the following code, in which Boost.Local uses a function callback to load

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.