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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:44:12+00:00 2026-05-16T03:44:12+00:00

I am not sure why this works but not when I pass in numbers

  • 0

I am not sure why this works but not when I pass in numbers

<form id="form1" runat="server">
    <div id="facebookPhotos-iFrameContent">
        <div>
            <p>Log in</p>
            <p id="LoginButtonContainer"><input type="image" id="btnLogin" src="images/loginBtn.jpg" /></p>
            <p><select id="facebookAlbumDropdown" /></p>
            <div id="facebookPhotosContainer" />
        </div>
    </div>
</form>

AddDropdownItem("-Select something test-", "-1", "testDropdown");

function AddDropdownItem(sText, sValue, sDropdownID)
{
      $("#" + sDropdownID).append("<option value=" + sValue + ">" + sText + "</option>");
}

that works

but this does not:

var id = 104388426283811;
AddDropdownItem("-Select something test-", id.toString(), "testDropdown");

What happens is the default option shows up but then when it tries to add the second option it bombs out with no errors that I can see in the firebug console and then in the end the list goes blank (no options) when my code is done running.

  • 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-16T03:44:13+00:00Added an answer on May 16, 2026 at 3:44 am

    Based on the comment thread in the original question, here’s my sample page that incorporates your logic (along with wiring up a button to add options to the select):

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>jQuery Test</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script language="javascript"> 
        $(document).ready(function() {
            $("#btnClick").click(function(e) {
                e.preventDefault();
                var id = 104388426283811;
                AddDropdownItem("-Select something test-", id.toString(), "testDropdown");
                //AddDropdownItem("-Select something test-", "-1", "testDropdown");
            });
        });
    
        function AddDropdownItem(sText, sValue, sDropdownID)
        {
              $("#" + sDropdownID).append("<option value='" + sValue + "'>" + sText + "</option>");
        }
    </script>
    </head>
    <body>
    
     <input id='btnClick' type='submit' value='click'></input>
    <p><select name="MyTestDropdown" id="testDropdown"></select></p>
    
    
    </body>
    </html>
    

    I don’t have the iframes that you mentioned, but I’m using an input submit element to add items in. I’m preventing the default behavior of a submit button by calling e.preventDefault();, which then prevents the post back. I’m then able to add items to the select element.

    I hope this helps.

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

Sidebar

Related Questions

I found this in Ryan Bates' railscast site, but not sure how it works.
Sorry if very primitive question but I am not sure how does this works
Not sure if I've just missed something but this doesn't work: $(this).children('td.threadtitle a').html('thread title');
This may be a stupid question, as I'm not sure how MSBuild works with
Not sure this is possible, but looking to write a script that would return
Not sure if this is the right spot to ask but I'm having a
I'm not sure if this is doable, but I will just give a shot.
Not sure exactly what I need to do to make this work, so my
I'm still not sure I totally get how this particular case should work out.
I am not sure whether I am asking this with the right words, I

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.