javascript for textbox or prompt using servlet 1 Answer(s) 2 years and 10 months ago
Posted in : JSP-Servlet
Dear sir I am writing script in servlet,so prompt() is not working here so please help me...In my project when a vendors want to delete the uploaded file ,if they are confirmed to delete the i have to take a reason for deleting a textbox as to come if press ok then delete the file then i have to store that reason in a data base so how to do in servlet.please help me..
My code is as follows out.println("function del(path,xxx){"); out.println(" var Cv = null;"); out.println(" Cv = confirm(\"Are you sure to delete the file?\");"); out.println(" if(Cv){"); out.println("if(path == \"detach\"){"); out.println(" var reason=prompt('Reason for deleting:','')"); out.println("document.attach.CatId.value=xxx;"); out.println("document.attach.action=\"../servlet/del_files\";"); out.println("document.attach.submit();") out.println("}"); out.println("}"); out.println("}");
public class Servlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException{ PrintWriter out = response.getWriter(); out.println("<html><head><script>function deleteRecord(id){var r=confirm('Are you confirm')"); out.println("if (r==true){var reason=prompt('Reason for deleting:')"); out.println("window.open('http://localhost:8080/examples/modified/deleteuser.jsp?id='+id+'&&reas='+reason,'mywindow','width=500, height=350,toolbar=no,resizable=yes,menubar=yes')"); out.println("}}</script></head>"); out.println("<form name='form'>"); out.println("<table border='1'>"); out.println("<tr><th>FirstName</th><th>LastName</th><th>Address</th><th>Email</th></tr>"); Connection con = null; String url = "jdbc:mysql://localhost:3306/"; String db = "test"; String driver = "com.mysql.jdbc.Driver"; String userName ="root"; String password="root"; int sumcount=0; Statement st; try{ Class.forName(driver).newInstance(); con = DriverManager.getConnection(url+db,userName,password); String query = "select * from employee"; st = con.createStatement(); ResultSet rs = st.executeQuery(query); while(rs.next()){ out.println("<tr><td>"+rs.getString(2)+"</td><td>"+rs.getString(3)+"</td><td>"+rs.getString(4)+"</td><td>"+rs.getString(5)+"</td>"); out.println("<td><input type='button' name='edit' value='Delete' style='background-color:red;font-weight:bold;color:#ffffff;' onclick=\"deleteRecord('"+rs.getString(1)+"');\"></td></tr>"); } } catch (Exception e) { e.printStackTrace(); } out.println("</table>"); out.println("<form>"); out.println("</html>"); } }
2)deleteuser.jsp:
<%@page language="java"%> <%@page import="java.sql.*"%> <% String reason=request.getParameter("reas"); out.println("Reason is: "+reason); String id=request.getParameter("id"); int no=Integer.parseInt(id); int sumcount=0; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root"); Statement st = conn.createStatement(); st.executeUpdate("DELETE FROM employee WHERE userid = '"+no+"'"); out.println("<br>Record is deleted successfully"); } catch(Exception e){} %>
Hope that it will be helpful for you. Thanks
Related Pages:
javascript for textbox or prompt using servlet - JSP-Servlet javascript for textbox or promptusing servlet Dear sir
I am writing script in servlet,so prompt() is not working here so please help me... ,if they are confirmed to delete the i have to take a reason for deleting a textbox as to come
javascript for textbox or prompt using servlet - JSP-Servlet javascript for textbox or promptusing servlet Dear sir,
I am using a prompt(),when a delete is confirmed,its working fine ,but when a prompt is closed or cancel ,i have to remain in the same page but here it is going
javascript for prompt - JSP-Servlet javascript for prompt Dear sir,
I have used prompt() for taking a reason while deleting using java script its working fine but prompt was coming at the top left so i want that prompt should come at middle so how to do
javascript for prompt - JSP-Servlet javascript for prompt Dear Sir,
I am using a prompt() for taking... a prompt contains any special character or what.If contains a alert message has... then that prompt was not coming..So please tel me how to validate a prompt
javascript for prompt - JSP-Servlet javascript for prompt Dear sir,
I am usingprompt()for taking a reason from vendor .
var reason=prompt('Reason for deleting:','');
Then i... an object ,so how to remove this script error.And also this prompt is coming
javascript for textbox - JSP-Servlet javascript for textbox Dear Sir,
In my project if i use a
var reason=prompt(\"Reason for deleting:\",\"\") in a javascript
after confirm the delete option ,its not invoking the prompt()...So please help me..
Thanks
javascript for textbox - JSP-Servlet javascript for textbox Dear sir ,
How to write a javascript for a textbox ?.I am doing a delet operation.When i clik on a particular record... a javascript to do so ..Please help me sir...
Thanks... Hi Friend,
Try
javascript for textbox - JSP-Servlet javascript for textbox Dear Sir ,
Thanks for posting an answer, its working fine .Sir how to get the text what we have entered in a prompt(reason... that value.I used the following code
reason=prompt("Reason for deleting
javascript prompt alert javascriptprompt alert Sending a prompt alert using a JavaScript function
javascript for textbox - JSP-Servlet javascript for textbox Dear sir,
Thanks for your post,but when i write
if(reason=="") i am getting a following error in eclipse i.e a red... written if(reason=="") in Scriptlets?You can write this code only in the javascript
prompt using prompt using I want examples to use prompt and how to move the item from the prompt to a cell in a table. thank you
Command Prompt in UI
Command Prompt in UI Hi One Help...
Please go through. I want to develop like that using jsp/javascript but nothing is striking in mind... Please give some suggestions to design first
Thanks in advance---- Vanchinathan.R
How to check text in textbox using JavaScript
How to check text in textboxusing JavaScript How to check text in textboxusingJavaScript
I have a form in HTML that contains text feilds... me.
JavaScript validation example to check text in textfeild
<
Javascript generate textbox Javascript generate textbox
In this tutorial, you will learn how to generate a textbox on button click
usingjavascript. Here is a javascript example... of textboxes. On clicking the
button with respect to each textbox, it will give
javascript
javascript hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format usingjavascript, and when i click on button then number of days should be display in textbox
javascript - JSP-Servlet
javascript using below code i got value in textbox but i also wants to use this textbox value in query in same page..
function passVariable(){
var v=document.form.txt.value;
document.form.txt1.value=v;
}
Enter
javascript error in IE - JSP-Servlet javascript error in IE Please Help me,
I have an urgent requirement i.e. JavaScriptprompt box is not working in IE. It Works firefox,safari... in the Internet Options->customlevel changes.
How to do displayin the prompt box using
command prompt is compilation is not working
command prompt is compilation is not working Dear java users can anyone help me to run the program in command line prompt i tried by selecting... is compiling and generation the class file using javac c:\helloworld.java command
how to get data using dropdownlist, textbox and search button in jsp
how to get data using dropdownlist, textbox and search button in jsp Hi,
I want to display data using jsp,javascript and mysql.
My Q. is
If i select...' in textbox and click on search button it should show me all the title names
Prompt
into methods in the method asking for the input it uses a prompt command...)
{
System.out.print(**prompt** + ' ');
return numberOfGrades
}
I don't undersant the prompt part
Autocomplete textbox with database in jsp and follow the MVC model
Autocomplete textbox with database in jsp and follow the MVC model i have one problem in my project i try to generate the autocomplete textbox... using ajax.
1)auto.jsp:
<%@page import="java.sql.*"%>
<html>
<
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp How to show data from database in textbox in jsp
Here is an example that retrieve the particular record from the database and display it in textboxusing JSP.
<
how to make enable/disable textbox in while(rs.next)
how to make enable/disable textbox in while(rs.next) Hi, I'm trying to enable/disable the textbox in the while loop. It works but when i want.../disable function,the data are updated correctly. Is my javascript wrong? How do i
how to make enable/disable textbox in while(rs.next)
how to make enable/disable textbox in while(rs.next) Hi, I'm trying to enable/disable the textbox in the while loop. It works but when i want.../disable function,the data are updated correctly. Is my javascript wrong? How do i
Enabling the textbox - Java Server Faces Questions
Enabling the textbox Hi,
I have disabled the jsf text box usingJavaScript on clicking the select boolean check box and it's getting disabled too.
but when I am trying to enable it again on clicking of checkbox
Javascript change textbox background Javascript change textbox background
In this section, you will learn how to change the background of textbox. Here
we have created a textbox and allowed the user to enter the valid name. If the
entered name is 'roseindia
Getting mysql table in textbox
Getting mysql table in textbox how to get mysql table values into textbox in java using ajax and servlets
Excel Prompt User on Focus
Excel Prompt User on Focus
In this section, you will learn how to prompt user on focusing the cell using
Apache POI.
EXAMPLE
In the below example, you will learn how to prompt user on focusing the cell.
Here, the message title
javascript - JSP-Servlet
javascript i dont have the jsp code .
using simple jsp file and without using alert message box.i need using of getElementByID
javascript - JSP-Servlet
;i dont have the jsp code .
using simple jsp file and without using alert message box.i need using of getElementByID
javascript - JSP-Servlet
callingaction.do will go to action class and retrieve values there using database
listbox and textbox validations
listbox and textbox validations hi,
any one please tell me how to set validations for listbox and textboxes using bean classes?
thank you...-registration-form-using-jsp.shtml
javascript - JSP-Servlet
javascript Hi sir,
I am storing the values in Map. when I am retreiving the values by using document.getElementById(). The keys are being retreived how can i get the values rather keys.
code
JAVASCRIPT
JAVASCRIPT I have one textbox and I want to validate that it must start with number(1-0). can anyone tell me a javascript for that ?
thanks in advance
javascript programing error - JSP-Servlet javascript programing error hi deepak
i m using explorer to run javascript program in this there is no option to check error will u plz tell me the way to check error in explorer as we can check with mozila
javascript date validation using regex javascript date validation using regex Hi,
I want to validate the date usingjavascript. Please help.
<html>
<head>
<title>Validating Date format</title>
<script type="text/javascript">
date in textbox on page load
date in textbox on page load i want to insret the current date in textbox but this code dosen't work and the value of text box will be blank
<script type="text/javascript">
function addDate
javascript problem javascript problem hi guys
My problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter the text button inside the radio button if I press no button then no any other textbox
Solve using only Javascript loops...
Solve using only Javascript loops... Write a JavaScript code,
1...) that reads the date of a day in one textbox, the month in a second textbox and the year in a third textbox. After submitting the form, it should display
Sql Server 2008 with textbox
Sql Server 2008 with textbox **Hi, I tried to insert into DB usingtextbox in a form using vb by visual studio 2010 but its always catch an error
[Cannot open database "4" requested by the login. The login failed.
Login failed
Call servlet from javascript - JSP-Servlet
Call servlet from javascript Hi in my application i have jsp that designs view, javascript for validation and servlet that perform business logic... the read column values present in grid and pass it to servlet along with url
Javascript
Javascript How validations are done usingjavascript ,with example? and interview questions on javASCRIPT
javascript
javascript write a program to display implement about browsers usingjavascript
Ajax drop down and textbox
.
<html>
<head>
<script language="javascript" type="text/javascript">
var xmlHttp
var xmlHttp
function
javascript code problem - JSP-Servlet javascript code problem Thanks for sending answer.but actually what... hidden variable and write javascript code so that all tables values are added to the variable.using that variable we can extract the data in database using string
Html/JavaScript code - JSP-Servlet
Html/JavaScript code I have 2 JSPs JSP1 and JSP2.
1.in JSP1 i have a table being displayed using the tag and cells in it contain links(huge amount of data is displayed in paged manner).
2.When click on a link, it leads