Execute JavaScript function using JSTL conditionals

Can a JavaScript function be invoked within an if statement using JSTL?

Here is the code snippet:

<c:choose>
<c:when test="${orderUploadAction.errors.size()==0}">

CALL JS FUNCTION INSIDE IF STATEMENT

</c:when>
<c:otherwise>

CALL JS FUNCTION INSIDE ELSE STATEMENT

</c:otherwise>
</c:choose>

Answer №1

Give this a shot

<c:choose>
  <c:when test="${orderUploadAction.errors.size()==0}">
     <script> tryThisFunction() </script>
  </c:when>
  <c:otherwise>
     <script> attemptAnotherFunction() </script>
  </c:otherwise>
</c:choose>

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

Button for copying URL and pasting it to clipboard available for use on desktop, iOS, and Android platforms using JavaScript

Is it feasible to use JavaScript/jQuery to copy the current URL and paste it into the clipboard using pure JS? Specifically, I am targeting phone users, like those with iPhones running Safari. I want to create a button that can automatically retrieve the ...

Tips for choosing the most recent entry for each category in a MongoDB database using typescript and mongoose

My mongoDB collection is structured like this: [ {user: "joe", event: "foo", timestamp: 1}, {user: "meg", event: "blah", timestamp: 2}, {user: "rick", event: "bork", timestamp: 3}, {user: "joe", event: "bing", timestamp: 4}, {user: "meg", event: " ...

Prevent the input from being erased when inserting innerHTML

I have been developing a form that allows users to dynamically add extra input fields by clicking on a button. The structure of the form is as follows: <div> <input type="text" placeholder="existing"/> </div> <button class="add"& ...

Utilizing Vuejs to dynamically set an id tag in a web application

I am working on a vue.js template with a todo prop, and I would like to dynamically set the id value of each element. Currently, my code snippet looks something like this. Is it possible to achieve what I want with this approach or are there other altern ...

What is the best way to extract a single value from my directive scope?

I am working with an AngularJS directive that has a non-isolated scope, but I have one variable, "isOpen," that needs to be isolated within the directive. Consider the following example: app.directive('myDir', function() { return { r ...

What are the steps to setting up SystemJS with Auth0?

I am having trouble configuring SystemJS for Auth0 (angular2-jwt) and Angular 2.0.0-beta.6 as I keep encountering the following error message: GET http://localhost:3000/angular2/http 404 (Not Found)fetchTextFromURL @ system.src.js:1068(anonymous function) ...

The extensive magnetic scrolling functionality in Ionic 2 sets it apart from other frameworks

Hi everyone, I could really use some assistance! I've been working on developing an Ionic 2 App and my navigation setup is not too complex. I have a main menu where clicking on an item opens another menu with a submenu. From there, if I click on an i ...

Dynamic JPA repository implementations for Spring applications

I have a substantial number of tables, approximately 30, that I need to populate from an XML file. My intention is to utilize JPA for this task. Currently, I have 30 classes that are annotated with @Entity and a configuration that scans entities and repos ...

Applying REGEX on input text in React Native

I'm having trouble getting my regex function to work correctly, so I believe there might be an error in my code. Any assistance would be greatly appreciated. Here is the regex function I am using: let validatePlate = (plate) => { var re = /(^[A ...

Combining duplicate values in MongoDB using aggregation

In my code, I have an aggregate function that counts the occurrences of a value in the database: let data: any = await this.dataModel.aggregate( [ { $match: { field: new ObjectID(fieldID), }, }, ...

Can Keyboarddatepicker automatically format the date?

We are utilizing material ui Keyboarddatepicker in our React application and have specified the date format using props as format=DD/MMM/YYYY, resulting in dates being displayed like "10/12/2020". The date picker functions perfectly when selecting a date. ...

Guide on using JavaScript to extract and display a random text from a datalist upon clicking with the onclick event

Is there a way for a JavaScript function to select a random sentence from a datalist within the same file and display it upon clicking a button with an "onclick" event? I'm new to JavaScript and seeking the simplest solution. Can anyone provide an exa ...

Struggling to constrain a TextField component from material-ui and encountering an issue with the inputRef

Currently, I am attempting to restrict the length of an autocomplete textfield within my project. However, when I apply InputProps={{ maxLength: 2 }}, it throws an error stating that my inputRef.current is null. Even though I have set the ref in the inputR ...

Attempting to convert Spotify's response string into a JSON object using Node.js

Lately, I've been utilizing the Spotify API through AJAX in the browser without any issues. However, now that I'm attempting to use it with node.js, I'm encountering a syntax error when trying to parse the string into a JSON object. Here&apo ...

Importing JSON data from a URL to display in an HTML table

Looking to utilize the Untappd API for a beer menu project, I've encountered an issue. The goal is to showcase the JSON data received from the server and organize it into an HTML table. Despite successfully importing data from a local list.json file ...

Require assistance with an unoccupied Django dialog box

Looking to implement a popup in a django template, but encountering an issue where the popup appears empty. Below is the current code: <input type="button" value="{{ account.account_id }}" class="btn btn-primary" data-toggle="modal" data-target="#myMo ...

Fatal Error: Java Native Interface StringUTFChars Retrieval Failure

As a robot enthusiast, I am currently working with my "Robotic Arm Edge" and the USB Interface to create custom software using Java Native Interface (JNI). Unlike ATK+ library for C/C++, Java offers a simpler way to design a GUI interface. The main reason ...

Executing JavaScript code with Node.js while utilizing Selenium

Seeking guidance as a beginner in Javascript, I apologize if my question is too basic. I am attempting to execute a Selenium test written in Javascript. Starting with a simple task of loading Google using chromedriver, I encountered an issue while running ...

What is the best way to access a variable from a class in ES6?

Hey there, I'm having trouble accessing the variable from the KeyCodeClass. Let me walk you through what I've tried so far: Attempt 1 class KeyCodeClass1 { constructor() { this.space; } KeyDown(e) { if (e.keyCode == 3 ...

Navigating between different windows in Selenium 2 using Java

Hey there! I'm currently trying to switch to a popup window and click a button on that popup, but for some reason I keep encountering errors. Check out this sample webpage: Here's the code snippet I'm using: for (String handle : driver.g ...