Execution of Javascript within Joomla articles or modules appears to be unsuccessful

Seeking assistance with a Javascript filter issue. The code functions correctly outside of Joomla, but when integrated into Joomla, it fails to execute. Suspecting a conflict or blockage hindering its operation.

Tried inserting the code using Sourcerer and Flexi code within a module, but no success. Explored solutions on Stackoverflow to no avail.

No known blockers like RS Firewall are present; verified JCE settings and article options granting JavaScript permissions.

What could be causing this problem? How can I resolve it?

Code snippet:

<script>
function myFunction() {
var input, filter, table, tr, td, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
} 
}
}
</script>

Have confirmed that the code is functional independently from Joomla. Integration with Joomla poses the challenge.

Grateful for any assistance provided!

Edit: Test page created: test filter table JavaScript snippet located around line 702 in the source.

Thank you!

Answer №1

It's actually quite simple. You've added the necessary code, but you forgot to call it. The example from w3c includes an event binding that I don't see in your source code.

Take a look at this:

<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names..">

Your current code:

<input id="myInput" title="Type in a name" type="text" placeholder="Search for names.." />

You need to call the function myFunction() somewhere in your code. If you can't add the onkeyup directly to the input field, you can use this JavaScript snippet instead:

$( document ).ready(function() {
    jQuery('#myInput').on('keyup', myFunction);
});

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

When the 'Show More' button is clicked, one Div will smoothly slide over another Div

I've been struggling for hours to find a way to make one DIV slide over another DIV below it instead of pushing it down. The setup is quite straightforward. I have a script that reveals more text when the 'Show More' button is clicked. Desp ...

What could be causing the npm mysql module to malfunction when trying to initiate the 'connect()' function in a separate .js file?

When I call require('mysql') and use the function connect() everything works fine. However, if I try to call the 'connect()' function in another file, it throws an error saying connection.connect is not a function... Any suggestions on ...

Fade the current Div out and fade in the following Div while also animating its child element

Looking to achieve a fade in and out effect for 3 divs, with the child element animating its way up from the bottom right once the divs have faded in. I've been working on it but haven't made much progress, does anyone have any ideas? Check out ...

Is there a way to retrieve files from a main directory as well as all its subdirectories?

I'm looking to find a way to retrieve all JavaScript files located in the main directory and any subdirectories for my discord.js command handler. How can I make this happen? I have a functioning code snippet that successfully retrieves all .js files ...

Angular Code Splitting with Webpack

My current project setup is causing some loading issues due to the large download size of Angular Material. As a result, a white screen remains loading for around 45 seconds. I have attempted to implement code splitting to enhance the loading speed of my a ...

Modifying the geometry of a plane in Three.js

Currently working on a simple terrain editor. When the mouse is clicked, I want the selected face to move up. The intersection is functioning well, and I am attempting to adjust the geometry in this manner: var intersects2 = ray.intersectObjects([ ...

Getting the image name and extension in an Angular application

Within this block of code, I am working with an image named xyz.abc.jpg. I am able to extract the image extension successfully, but now I need to figure out a way to extract the image name itself without the extension included. Is there a way to achieve ...

The functionality of jQuery touch events on iOS devices is not functioning properly

I'm encountering issues with jQuery touch events on iOS devices. Here is my current script: $(document).ready(function(){ var iX = 0,iY = 0,fX = 0,fY = 0; document.addEventListener('touchstart', function(e) { ...

Utilizing ngRepeat to build intricate rows within a table

I have a unique collection that appears as follows: { "10": {}, "12": { "20": { "value": 1, "id": 1, }, "100": { "value": 12, "id": 1, } }, "14": { "10 ...

The full screen menu is exclusively displayed in the navigation bar

My HTML and CSS code is causing an issue where the full-screen menu only appears in the nav bar. This problem seems to be specific to Safari. To solve the issue, I need to remove the following code: .nav { position: fixed; } However, I still ...

What is the best way to clear a THREE.JS scene?

I am exploring methods to remove all objects from a scene without affecting the scene structure. I understand that naming each object individually allows for selective deletion by name. But, I am searching for a fast approach to clear a scene of all obje ...

Leveraging URL parameters to automatically enable the initial selection in a linked dropdown menu and trigger an OnChange event

Project Description: I have successfully implemented a search form with 5 dependent drop-down menus that are crucial for filtering data. The first dropdown, labeled dim_id, is chosen on the product_request page and triggers an OnChange event which sends th ...

Nested modal in native app utilizes the React Carbon TextInput component for an uneditable input field

As a newcomer to React, I have encountered an issue with the Tauri framework used to bundle my React application as a desktop app. Specifically, I am facing a problem where the TextInput field, nested inside a modal and utilizing React Carbon components, i ...

Animating along a predetermined L-shaped route using the MotionGuide tool for tweening

Exploring Tween.js for basic animation has been an exciting journey. To create a ball moving along a predefined path, it appears that the MotionGuide plugin is necessary. You can find detailed information about it here: I am interested in having my objec ...

Parsley JS failing to validate

I attempted to validate my form using parsley.js, following the instructions from the official documentation. However, for unknown reasons, it is not functioning as expected. Below is the code snippet: <div class="container"> <div class= ...

I am experiencing difficulties with my focusin not functioning properly for the input element that I added

I am working on a program that includes a dynamic table with the following structure: <table id="selectedItems"> </table> I plan to use jQuery to append elements to it like so: var i=0; $("#selectedItems").html(''); $("#sel ...

Using Node.js Puppeteer to interact with dynamically generated elements

Currently, I'm utilizing puppeteer for node.js version 13.3.1 to develop a bot that will automate job applications on LinkedIn. The code I have so far is as follows: const puppeteer = require('puppeteer'); const SEARCHPARAM = "react& ...

Issue with debugging capabilities in Javascript on VSCode has been detected

UPDATE: I'm seeking guidance on configuring VSCode for debugging Javascript. While I'm familiar with JavaScript functioning in a browser, I find it tedious to rely solely on console.log(). I am looking to debug and step through my code effectivel ...

Troubleshooting Problem: Difficulty accessing Controller in AngularJS Module

I am facing difficulties with communication between my application and a module that I have developed. Below is the AngularJS module that I created. (function (document, window) { 'use strict'; var piCart = angular.module('piCart& ...

Strangely glitchy navigation bar using jQuery

Over at this website, there's a top navbar that shrinks using jQuery when scrollTop exceeds 100px. The functionality works as intended, but there's an annoying stutter issue where the navbar starts jumping up and down erratically after slight scr ...