JavaScript malfunctioning on Chrome

Displayed on the page is a table that lists user details. When the Edit Button is clicked, it allows for the row to be edited. The code provided below works in IE but does not show any response in Chrome. I am looking to make the site compatible with both IE and Chrome. I'm unsure of the reason why Chrome is not responding.

<td style="display:none;" class="bb">
    <input class="btn" type="button" value="Edit" style="width:40px;" 
        onclick="EnableUpdate(this.parentNode.parentNode);">
    <input class="btn" type="button" value="Save" style="display:none;width:40px;" 
        onclick="SaveUpdate(this.parentNode.parentNode);">
</td>

function EnableUpdate(oThisRow){
  DeactivateCurrentRow(oThisRow);
  var oCellsOfThisRow = oThisRow.childNodes;
  var i, oGroup

  oGroup = oCellsOfThisRow(4).lastChild;
  oGroup.options.length=0;
  for (i = 0; i< GroupID.length; i++)
  {
        oGroup.options[i]=new Option(GroupID[i], GroupID[i]);
        if(oGroup.previousSibling.innerText == GroupID[i])
        oGroup.selectedIndex=i;
  }  

  for(i=0;i<5;i++) 
    oCellsOfThisRow(i).lastChild.value = oCellsOfThisRow(i).firstChild.innerText;

  for(i =1;i<7;i++) {
    oCellsOfThisRow(i).firstChild.style.display = "none";
    oCellsOfThisRow(i).firstChild.nextSibling.style.display = "block";
  }
}

Answer №1

If you are loading your code using document onload, it may not work as expected. This is because the DOM is created first and the scope for onclick code is set at a time when the function is unknown.

window.onload = function(){
   function EnableUpdate(...){....};
}

This situation can occur easily if you are using jQuery and placing all your code within its wrapper:

$(function(){});

Instead of using the onclick attribute, consider using:

myElement.addEventListener('click',EnableUpdate);

Make sure to include this in the onload function as well.

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

Encountering an EJS error stating SyntaxError: a closing parenthesis is missing after the argument list in the file path C:Userscomputer pointDesktopproject2viewshome.ejs

Struggling to retrieve data from app.js through ejs and encountering an error. Pursuing a degree in Computer Science <%- include('header'); -%> <h1><%= foo%></h1> <p class = "home-content">It is a fact that readers ...

Jasmine and Karma encountered a TypeError stating that the function this.role.toLowerCase is not valid

Currently, I am in the process of writing a test case for a page within an application that our team is actively developing. However, I have encountered a challenging error within one of the test cases that I am struggling to overcome. Below is my Spec fil ...

The prop type `cellHeight` provided to `GridList` in (Material-ui / React) is invalid

warning.js:33 Warning: The prop type for cellHeight in the GridList component is invalid. I encountered this error message, despite the property functioning correctly. Is there a way to resolve this issue? If you're interested, check out the documen ...

Once you have reviewed the initial reply, proceed to send a follow-up message

Once I have received a response from the server for one string, my goal is to send the next JSON object. I need to verify the first object and then proceed to send the second one based on that verification. How should I handle the server's response? ...

When making an HTTP GET request followed by another GET request in Express, it results in an error with undefined parameters on the

When I open a form that has a link to a list and try to access the list, I encounter an "id" undefined error for the form we came from, which was already functional. The issue arises when I have a GET page where I present a form to modify a record at /loc ...

Angular JS - Establishing a Connection to Woocommerce OAuth v1

I'm having trouble authenticating myself with the rest service. I attempted to use this library to generate all the necessary parameters as mentioned here, and I constructed the request like this: $scope.oauth = new OAuth({ consumer: { p ...

Obtain custom parameter data from a string

Searching for custom parameter values within a string is necessary. For instance, given the following string: aaa[111] bbb[222] ccc[333] ddd[444] I am looking to extract the value 111 associated with the parameter aaa, and so on... The specific paramete ...

Can a hyperlink exist without a specified href attribute?

One scenario could be when I receive this specific code from a third-party source <a class="cs_import">Add contacts from your Address Book</a> Curiously, the link "Add contacts from your Address Book" does not redirect to any page as expected ...

Fetching Information From Database Using PHP

I am encountering an issue while attempting to transfer data from my HTML table to my modal (without using bootstrap). In the image below, you can see that I have successfully displayed data from MySQL database in the table. The problem arises when I clic ...

Leveraging the power of "react-bootstrap" through the npm package manager

I have a project in mind that involves using npm. Specifically, I want to incorporate react-bootstrap into it. To kick things off, I already have a package.json file with the necessary dependencies. { "name": "simple-webapp", " ...

Running multiple instances of setTimeout() in JQuery

I'm looking for a way to delay the execution of 10 lines of independent jQuery code with 2 seconds between each line. I initially tried using setTimeout() on each line, but is there a more elegant solution for this scenario? The jQuery DELAY method do ...

Having trouble getting a NodeJS sample app to start up because it can't locate the 'config' file?

I am currently delving into the world of Node.js and have been attempting to launch a sample application that I recently acquired from a git repository: https://github.com/madhums/node-express-mongoose-demo Despite diligently following all the provided i ...

Using React.js to Retrieve Data from the Server without AJAX Calls

Currently, I am in the process of creating a web application using Express.js for the back-end and React.js for the front-end. Prior to using React.js, I utilized EJS templating and followed a similar workflow on the back-end as shown below: var express = ...

Show a Toast in React without relying on useEffect to manage the state

I have successfully implemented the Toast functionality from react-bootstrap into my application using the provided code. However, I am unsure if it is necessary to utilize useEffect to set show with setShow(items.length > 0);. Would it be simpler to ...

Leverage Firebase cloud functions to transmit a POST request to a server that is not affiliated with

Is it feasible to utilize a firebase cloud function for sending a post request to a non-Google server? It appears that being on the blaze plan is necessary in order to communicate with non-google servers. Essentially, I aim to perform a POST action to an ...

Error: Unable to locate module: Could not find '@/styles/globals.scss'

I'm encountering an error message with my import statement for the SCSS file in my _app.tsx. Can someone help me find a solution? I'm working with Next.js and have already exhausted almost every resource available online to fix this issue. ...

Having trouble retrieving information from ajax to php

I'm struggling to understand why this code is not functioning as expected: idcurso= res[0]; idusuario= res[1]; semana= res[2]; fecha=res[3]; asistencia= true; $.ajax({ type: "POST", url: '/test/7/tomarasistencia.php', data: { ...

Troubles with submitting jQuery validation plugin via AJAX

Whenever I try to use the jQuery validation plugin for validating a form within a Bootstrap modal, the validation does not work and the form cannot be submitted. This is the code for the Bootstrap modal form: <div class="modal fade" id="form-content" ...

Managing simultaneous asynchronous updates to the local state

There is a scenario where a series of asynchronous calls are made that read from a local state S, perform certain computations based on its current value, and return an updated value of the local state S'. All these operations occur at runtime, with ...

Having difficulty creating JSON data following retrieval of rows by alias in MySQL

I am encountering an issue while trying to fetch rows from two tables using a JOIN and aliases. The problem arises when I attempt to convert the fetched rows into JSON data and assign them to a JSON array. Below is the code snippet: $personal = $db->p ...