Is there a way to pass the values of a text box in a JSP through a hyperlink on the same page? I want to achieve this but am not sure how.
Is there a way to pass the values of a text box in a JSP through a hyperlink on the same page? I want to achieve this but am not sure how.
Insert <a>
element and utilize QueryString
to transmit the content of a textbox to another JSP
page.
<a href="pass.jsp" onclick="addTextBoxData(this)">
<script>
function addTextBoxData(e){
e.href = e.href + "?textbox=" + document.getElementById('textboxID').value;
}
</script>
All that is required is to pass the reference of the tag using this
.
Subsequently, it will append the data as ?textbox=textbox value
Resulting in /pass.jsp?textbox=txt
When using the GET
method, you can create a file called index.jsp
.
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
<form method="get" action="index.jsp">
<table>
<tr>
<td><label for="txtUserName">Username: </label></td>
<td><input type="text" id="txtUserName" name="txtUserName"/><br/></td>
</tr>
<tr>
<td><label for="emailUser">Email: </label></td>
<td><input type="email" id="emailUser" name="emailUser"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
If you go to: http://localhost:8080/index.jsp
(assuming default port 8080 with Tomcat)
and enter the following:
username: myname
email:
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="eb8692858a868eab8e938a86b878515f1707d1315">[email protected]</a>
Submit
button, you will see the browser's address bar change to:
http://localhost:8080/index.jsp?txtUserName=myname&emailUser=myname%40example.com
I am currently developing a lottery application using React.js that features a spinning wheel in SVG format. Users can spin the wheel and it smoothly stops at a random position generated by my application. https://i.stack.imgur.com/I7oFb.png To use the w ...
Currently, I am utilizing the following AJAX code: $.ajax({ url: "Editor.aspx/Page_LoadComplete", data: { "contentCheckCode": contents }, type: "POST", success: function (response) { alert("Contents saved..."); }, error: fu ...
I've been facing issues with passing my trends variable from its function into a renderer for my Pug template. It's proving to be quite challenging. var express = require('express'); ...
I have this code snippet and I am attempting to understand how to search through an array of objects where the call() function is invoked multiple times? var arr = []; var newData; function call() { newData = $('a').attr('href'); ...
I am currently facing an issue with resetting the state of an object in my users array upon clicking the delete button. Even after successfully removing the object from the database, the state does not update as intended. I have managed to verify the prese ...
Currently, I am working on a custom WordPress theme that involves setting a session variable based on the value selected from a dropdown box. This session variable is then used to determine which container should be loaded. The code snippet below shows whe ...
Having some issues with importing pagination from modules in SwiperJs for my nextjs project. The error message "Module not found: Package path ./modules is not exported from package" keeps popping up. I have tried updating the module to the latest version ...
I customized my checkboxes using the icheck plugin to work with both single and multiple checkboxes, including a "Check all" option. Here is an example of how it looks in HTML: HTML : <div>Using Check all function</div> <div id="action" c ...
Will the server only serve the index.html file or is there a way for the client to run that html file as it's not a regular html file? Do I need a backend node to make it work? I'm having trouble understanding the entire process. Normally, a cli ...
$window 'popstate' event is not functioning properly in IE when using the browser back button. Here is the code snippet used to remove certain modal classes when navigating back. $(window).on('popstate', function(event) { event.pre ...
After diligently going through the official documentation and following the steps in the tutorial, I have successfully managed to access a node's data field and use it for labeling, as long as the key is a simple string. However, my data will contain ...
I need help with making my Ionic app responsive across all mobile devices. The design on the page was created using CSS, but it is not displaying properly on every device. How can I ensure that it adapts to different screen sizes? <template> <Io ...
My current challenge involves attempting to access a third-party API using AngularJS. Interestingly, I only encounter this issue in Chrome, as it works perfectly fine in IE. The error message that pops up reads as follows: XMLHttpRequest cannot load https ...
I'm currently in the process of transitioning from JavaScript to TypeScript within my create-react-app project. I am facing an issue where new ESLint TypeScript warnings are being flagged for my old .js and .jsx files, which is something I want to avo ...
I am currently designing a dynamic form where each Field contains a list of values, with each value represented as a string. export class Field { name: string; values: string[] = []; fieldType: string; constructor(fieldType: string) { this ...
I am facing an issue where I cannot figure out why the password checkbox always turns to checked even when it is supposed to stay unchecked. No matter what, it doesn't behave as I intended and I am struggling to explain this behavior... <template&g ...
Hey there, I've been searching for a solution to my problem even though it's been discussed before. I'm trying to achieve something simple: creating a string like distance is : " + CalculateDistance(position);. The desired result should look ...
How can I resize a button in Sencha Touch 2 to make it smaller? I need to change its height. Any sample code you could provide would be greatly appreciated! Thanks navigationBar: { items:[{ xtype: 'button', ...
I have been facing an issue while working on this code, constantly running into the error message: Unexpected token o in JSON at position 1 https://i.stack.imgur.com/43Ewu.png I am struggling to troubleshoot and was hoping for some advice or tips on r ...
Seeking assistance with managing audio on an iPad using JavaScript (mute/unmute). Any suggestions or advice would be greatly appreciated. ...