Click on an Object within a modal window using JavaScript in Internet Explorer 8

I'm facing a strange issue with the SELECT object in a Modal Window.

Within my HTML code, I have a button that opens a modal window when clicked. Inside this modal window, a JSP page is loaded. On this JSP page, there is a dropdown list created using the tag, along with a button that triggers a JavaScript function to display the selected items and ultimately send them back to the parent window. The problem arises when attempting to retrieve the length or selectedIndex values as it fails without any alert being displayed. Unfortunately, due to security restrictions within my Company, I am unable to access the error messages or view the source code.

Here's the snippet of code:

The JavaScript responsible for opening the modal window:

 var oReturnValue = window.showModalDialog('addnewfilters', '', "dialogHeight:505px;dialogWidth:300px;resizable:yes;center:1;"); 

The HTML and JavaScript within the Modal Window:

<!DOCTYPE html>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title> Add New Field as a Filter</title>
        <script type="text/javascript" src="js/filters.js">

        var oReturnObject = new Object();

        window.onbeforeunload = function()
        {           
              window.returnValue = oReturnObject; 
        }

        </script>
       <script type="text/javascript">
        /*
         * Adds a one or more Filters
         */
        function addNewField(selectObj){

            var sFields = "";
            var fieldsArray = new Array();

            alert("List name : " + selectObj.name);
            alter("List length : " + selectObj.length);

            for(i=0; i < selectObj.length; i ++){
               alert("Element : " + selectObj[i]);

               if (selectObj[i].selected){
                sFields = selectObj[i] + ",";
                fieldsArray.push(selectObj[i]);
               }  
            }                         
            oReturnObject.selFields = sFields;
            window.close();            
        }
    </script>
    </head>

    <body>                  
                <select id="filtersList" name="filtersList" multiple="multiple">
                     <option value="dtcreated">DTCREATED</option>
                     <option value="dtupdated">DTUPDATED</option>
                     <option value="vchstatus&gt;VCHSTATUS</option>
                     <option value="intjrnlcnt">INTLJRNCTL</option>
                </select>

                <button id="btnAddFilter" onClick="addNewField(document.getElementById('filtersList'))">Add Fields to Filter</button>
                <button id="btnCancel" onclick="window.close();">Cancel</button>                              

    </body>
</html>

Upon clicking the "Add Fields to Filter" button, I receive an alert displaying the SELECT tag's name but no subsequent alerts appear.

Could this be related to IE8 and modal windows? My testing in a regular window yielded successful results.

Answer №1

It is important to consistently monitor your error console:

The following code contains a syntax error.

alert("List length : " + selectObj.length);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Send JavaScript variable using a query parameter

I am working on passing a JavaScript variable across all pages in my project. The goal is to calculate the total value from various pages and display it at the end of navigation. Below is an example of my JS code: <script> $(document).ready ...

displaying a confirmation using jQuery in CodeIgniter

Hello everyone, I am a beginner in CodeIgniter and I am seeking assistance. I am attempting to create a confirmation message (div id="delmsg") using jQuery when deleting a record from MySQL database. The delete operation is functioning properly, but the me ...

ACE.js enhances website security through Content Security Policy

I've been working on setting up a helmet-csp with ace running smoothly. Here's how my helmet-setup looks: var csp = require("helmet-csp"); app.use(csp({ directives: { defaultSrc: ["'self'", "https://localhost:8000"], ...

Error in tabs.onUpdated argument in Firefox WebExtensions

I am currently working on developing a straightforward webExtension for Firefox and I would like to implement tabs.onUpdated with a filter. I found an example on the Mozilla website that I decided to use: const pattern1 = "https://developer.mozilla.org/*" ...

Instructions on utilizing the signUp() function in Supabase for including extra user details during the registration process

My latest project involves building a Vue.js application with authentication using Supabase. I've been trying to implement the signUp() method from Supabase in order to collect extra user data during the sign-up process. In my code, I added a property ...

What is the reason behind "Script" being considered the offspring of "Body"?

Unfortunately, I struggle with HTML/CSS/Javascript and am just trying to get through my exams. I have the code snippet below: <script> window.onload=function() { var c = document.body.childNodes; var txt = ""; var i; for ...

I encountered an error when attempting to integrate Node.js with my terminal in the text editor - permission was denied

After installing node.js and npm, I encountered permission issues when trying to run them from my text editor (VSC). I was advised to open the terminal within the text editor, drag and drop the .js files I'm working on, add "node" and hit "enter" to r ...

Using JavaScript to display a line using `document.write`

I'm having trouble displaying a line using the Document.Write function in JavaScript. When I submit the form, the line briefly appears and then disappears Any ideas on why this might be happening? <!DOCTYPE html> <html> <head& ...

Pass data from Wordpress plugin to JavaScript function

I recently developed a plugin for a WordPress website. Inside the plugin, I am trying to call a JavaScript function (passing a string as a parameter) from a file that I have just enqueued. However, nothing seems to be happening. Can anyone help me identify ...

Creating a basic bar graph using d3.js with an array of input data

In my dataset, I have an array of form data that includes items like 'Male', 'Female', 'Prefer Not To Say'. I want to create a simple bar chart generator using D3.js that can display the percentages or counts of each item in t ...

Iterate through the complex array of nested objects and modify the values according to specified conditions

I am currently iterating through an array of objects and then delving into a deeply nested array of objects to search for a specific ID. Once the ID is found, I need to update the status to a particular value and return the entire updated array. Issue: Th ...

I am looking for the best way to sort my JSON data based on user roles before it is transmitted to the front end using Express and MongoDB. Any

I scoured the internet high and low, but to no avail - I couldn't find any framework or code snippet that could assist me in my predicament. Here's what I'm trying to achieve: whenever a response is sent to my front-end, I want to filter th ...

Deactivate the date when it reaches 8 in the current date count using ajax, php, and mysql

I want to prevent users from selecting a specific date after it has been chosen 8 times. Currently, when the date is selected for the 9th time, an alert box pops up. Instead of the alert box, I would like to disable that particular date selection altogethe ...

What is the best way to store the outcome of a promise in a variable within a TypeScript constructor?

Is it possible to store the result of a promise in a variable within the constructor using Typescript? I'm working with AdonisJS to retrieve data from the database, but the process involves using promises. How do I assign the result to a variable? T ...

Is it possible to retrieve the HttpsError status from a Firebase function?

Within my firebase function, I deliberately throw an error with a specific status and message using the following code: throw new functions.https.HttpsError('permission-denied', 'Token does not match'); When I receive the server respo ...

Tips for properly updating the shadow when modifying the vertices of custom geometry in A-Frame/three.js

I've developed a custom component in a-frame that generates a unique geometry. I'm using the tick function to animate the update of the geometry's vertices successfully. However, the shadow on the geometry doesn't seem to update accordi ...

Challenge encountered with asynchronous angular queries

Dealing with asynchronous calls in Angular can be tricky. One common issue is getting an array as undefined due to the asynchronous nature of the calls. How can this be solved? private fetchData(id){ var array = []; this.httpClient.get('someUrl ...

Using jQuery UI datepicker - how to set a parameter based on a specific condition

New to the world of JavaScript, I am trying my hand at implementing the jQuery UI datepicker widget. My goal is to add an additional line to the widget parameters if the variable selectedDate has a value. However, my current approach seems to be ineffecti ...

Guide to placing an image in a designated position

I am looking to achieve the following scenario: Whenever a user uploads an image, it should appear in one of the smaller boxes on the right. Subsequent image uploads by clicking on the big box should populate the other small boxes on the right. Please refe ...

Uploading multiple strings to an Amazon S3 bucket using Node.js by piping a string

Suppose I have a simple loop similar to the one shown below: for (const i=0; i<3; i++) { to(`This incrementer is ${i}`) } At the end of the loop, I expect my file to contain: This counter is 0 This counter is 1 This counter is 2 I at ...