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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:03:33+00:00 2026-05-24T11:03:33+00:00

I cannot seem to get the value from a select option that has been

  • 0

I cannot seem to get the value from a select option that has been dynamically created when viewing in IE6/IE7. IE always returns undefined as the value.

I have a set up a fiddle, and below is the complete source of an example (in case you attempt to use fiddle in IE6/7 …heh):

<!doctype html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
var json = "blah blah blah";

jQuery(document).ready(function(){

    $('#myForm').html('<select id="sg-1" class="setgroup" name="sg-1"><option value="s-1">Something</option><option value="s-2">Another</option><option value="s-3">Third</option><option value="s-4">Fourth</option></select>');

    $('.setgroup').live('change',function(){
        updateSelected($(this + ':selected').val(), json);
    });

});

function updateSelected(value, json){
    //do some stuff with the json in my app
    $('#selected').html(value + ' was selected');
}
</script>
</head>
<body>
<form id="myForm">
</form>
<p id="selected" style="font-size:20px; color:#f00;"></p>
</body>
</html>

The examples use live(), however I have also tried a variation using .delegate(). Both methods work in all browsers except IE6/7. I have tried using click as the event as well. Any ideas?

I also tried the solution(s) provided here. The problem seems to be in $(this) not being interpreted correctly, as if I place an alert inside of the live/change/delegate it will fire properly.

  • 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-24T11:03:34+00:00Added an answer on May 24, 2026 at 11:03 am

    $(this + ':selected') will not work. It will try to concatenate the string representation of a DOM element, which will probably be [object HTMLSelectElement], with :selected, resulting in the “selector” $('[object HTMLSelectElement]:selected').

    I think you just want $(this). A select cannot be selected anyway.

    In general, if you already have a set of selected elements, you can filter for certain elements with .filter() [docs]. If you want to find specific descendants, then use .find() [docs].


    However, you can also attach the event handler after you inserted the element:

    // or $('#sg-1').change(...
    $('.setgroup').change(function(){
        updateSelected($(this).val(), json);
    });
    

    DEMO

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

Sidebar

Related Questions

I cannot seem to get hold of the parent varible from the child template,
So I'm having two issues that I cannot seem to get unkinked. I run
If I add some OPTION's to a select list from client side javascript, that
I cannot get my addslashes function and html option value to play nice together.
I have this design which I cannot seem to get right, I would like
I need a function, but cannot seem to get it quite right, I have
I'm terribly new to SQL, and cannot seem to get the desired information out,
This is a very old problem, but I cannot seem to get my head
So obviously I am doing something wrong, but I just cannot seem to get
How can I get jaxb to bind to my Vector? I cannot seem to

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.