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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:25:58+00:00 2026-06-08T08:25:58+00:00

I have a jsp page which is using JavaScript for automatic selection in onload

  • 0

I have a jsp page which is using JavaScript for automatic selection in onload page event
and some jQuery to dynamically expand different div tags with some content inside.

So the problem is that the calling of the setSelection method, which is in the bottom of the page in script tags, and the jQuery methods which are in a js method called toggle doesn’t work at all in IE8. However in Chrome, Firefox and IE9 it works fine.

I’ve Googled this issue a lot but I can’t find anything useful. The only errors which the debuger tool in IE8 show me are “Object required” and “Expression required”.

Here is the code:

                        <html>
        <head>
            <script type="text/javascript" src="jquery-1.7.2.js"></script>
            <script type="text/javascript">
                function toggle(el)
                {
                    var val = el.options[el.selectedIndex].value;
                    if (val == "1")
                    {
                        document.getElementById("2").style.display = "none";
                        $("#1").slideToggle(250);
                    }
                    else if (val == "2")
                    {
                        document.getElementById("1").style.display = "none";
                        $("#2").slideToggle(250);
                    }
                    else if (val == "0")
                    {
                        document.getElementById("1").style.display = "none";
                        document.getElementById("2").style.display = "none";
                    }
                }
                function setSelection(selection) 
                {
                    //Here we make dynamic selection of the combo box
                    var selct = document.getElementById("sel");
                    selct.options[selection].setAttribute("selected", "selected");
                    toggle(selct);
                }
            </script>
        </head>
        <body>

        <select name="mySel" id = "sel" onchange="toggle(this);">
            <option value="0">Zero</option>
            <option value="1">One</option>
            <option value="2">Two</option>
        </select>
        <div id="1" style="border:1px;">
        </div>
        <div id="2" style="border:1px;">
        </div>
        <script>
            setSelection(0);
        </script>
        </body>
        </html>

Can somebody help me?

  • 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-08T08:26:01+00:00Added an answer on June 8, 2026 at 8:26 am

    Wrap your code in document ready function and try.

    jQuery(document).ready(function($) {
        // Stuff to do as soon as the DOM is ready. Use $() w/o colliding with other libs;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a popup using div and javascript in a jsp page which also
I have a JSP page (home page) in a Web App, which has different
I have a JSP Page which I am using to redirect to another url
I have a jsp page which should load a popup using ajax. The content
On a Jsp page I have some select elements which were disabled after a
I have a JSP page which accepts SQL queries, performs them then returns the
I have a jsp page which needs a java code. This java code inside
I have a jsp page, which imports another jsp. This import is wrapped into
I have a JSP page, which accepts user strings in more than 23 languages.
There is a JSP page in which i have an ArrayList variable. I need

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.