Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet javascript for textbox

Have Programming Question? Ask it here!
 
 
 


harini
javascript for textbox
1 Answer(s)      3 years and 10 months ago
Posted in : JSP-Servlet


Dear Sir ,
Thanks for posting an answer, its working fine .Sir how to get the text what we have entered in a prompt(reason).I need that reason to be displayed one next delete.jsp page so how to get that value.I used the following code
reason=prompt("Reason for deleting:","");
window.open('../delete.jsp?id=id&reason='+reason.value,'mywindow','width=500, height=350,toolbar=no,resizable=yes,menubar=yes');

In delete.jsp

If i do request.getParameter("reason"); i am getting a null value .So please help me ..
Thanks...

Advertisement
View Answers

July 13, 2010 at 4:50 PM


Hi Friend,

Try the following:

1)user.jsp:
<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function deleteRecord(id){
var r=confirm("Are you confirm");
if (r==true)
{
var reason=prompt("Reason for deleting:","");
if(reason==""){
}else{
window.open('http://localhost:8080/examples/jsp/deleteuser.jsp?id='+id+'&&reas='+reason,'mywindow','width=500, height=350,toolbar=no,resizable=yes,menubar=yes');
}
}
}
</script>
</head>
<body>

<br><br>
<table border="1">
<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()){
%>
<tr><td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<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();
}
%>
</table>
</form>
</body>
</html>

2)deleteuser.jsp:

<%@page language="java"%>
<%@page import="java.sql.*"%>
<%
String reason=request.getParameter("reas");
out.println("Reason is: "+reason);
System.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){}
%>

Thanks


Related Tutorials/Questions & Answers:
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, 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
Advertisements
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
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).I need that reason to be displayed one next delete.jsp page so how to get
Javascript generate textbox
Javascript generate textbox In this tutorial, you will learn how to generate a textbox on button click using javascript. Here is a javascript example... of textboxes. On clicking the button with respect to each textbox, it will give
How to check text in textbox using JavaScript
How to check text in textbox using JavaScript  How to check text in textbox using JavaScript I have a form in HTML that contains text feilds... me.   JavaScript validation example to check text in textfeild <
javascript for textbox or prompt using servlet - JSP-Servlet
javascript for textbox or prompt using 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 prompt using 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 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
passing textbox value from one page to another page using html n javascript
passing textbox value from one page to another page using html n... of variable at onclick event of button and also want to print it in textbox...)page2.html: <html> <script LANGUAGE="JavaScript"> function getParams
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
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
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox
showing the information of database in textbox
showing the information of database in textbox  how to make a information of a database make appear to the user in the textbox
Getting mysql table in textbox
Getting mysql table in textbox  how to get mysql table values into textbox in java using ajax and servlets
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
Dynamically adding textbox and labels
Dynamically adding textbox and labels  Sir, In my application I want to insert texbox and labels dynamically and want to insert database field value in that generated label. Plz help me, Thanks in advance
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
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   Please visit the following link: http://www.roseindia.net/jsp/user
retaining textbox values
retaining textbox values  i have a calculator program, when i press a button the value displays but disappears when i press another button so how can i keep values to display when i press multiple buttons
Sql Server 2008 with textbox
Sql Server 2008 with textbox  **Hi, I tried to insert into DB using textbox 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
Dynamically hide textbox
. AVOID PAGE REDIRECTING jsp+servlet+oracle+javascript I am using
Ajax drop down and textbox
. <html> <head> <script language="javascript" type="text/javascript"> var xmlHttp var xmlHttp function
Dynamically Update textbox from database
Dynamically Update textbox from database  I have a database as shown... with two text boxes. if I type something in one textbox, the corresponding value... in another textbox. How can I achieve
get date picker values to a textbox
get date picker values to a textbox  I am using DatePicker to select date in a form in asp.net using c#. I need the picked data to get in to a textbox. Please help me soon
display he new customer no in textbox
display he new customer no in textbox   i want to add the new customer for that when i click on add butto the new customernumber should be display in textfield . plz ell me the suggestions & code
JavaScript
JavaScript  clone JavaScript
binding data with textbox on dropdown click
binding data with textbox on dropdown click  Hello friends,Divyesh here. i have jsp page and i would like to bind data with text box on dropdown click. in dropdown employee id are load.and when we select perticular id than how
javascript
javascript  javascript code to dynamically add table on button click.../javascript/javascriptexamples/javascript-add-row-dynamically.shtml http://www.roseindia.net/javascript/javascript-add-row-to-table.shtml http://www.roseindia.net
Javascript
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
store dynamic generated textbox value into database
store dynamic generated textbox value into database  sir, how do i store dynamically generated textbox value into the database thanks in advance
JavaScript
should use JavaScript? Thanks   Hi, JavaScript is scripting language that runs on browser. You have to embed JavaScript in HTML page. Please see JavaScript tutorial. Thanks
JavaScript
JavaScript  how to get full path of a file type in javascript
javascript
javascript  Hi deepak, how to write form validation on javascript
javascript
javascript  write a program to display implement about browsers using javascript
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
javascript
javascript  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
How to display current date in textbox - Date Calendar
;% } This is my problem: I want to display current date in textbox, but it's failed. I don't know where is my mistake, but javascript value doesn't show in textbox. Please help me to solve that problem, I will wait your answer
Getting Textbox data from database
Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown below. <% String empid=(String) session.getAttribute("empid
javascript
javascript  how to set the request or session attribute in javascript head part of jsp page
javascript
javascript  hi sir, if i want to learn javascript. what concepts i want to know
javascript
javascript  Hi sir, This is sinduri, i want to learn javascript, so plz can u help me.how to learn
Retaining textBox values in java - Java Beginners
Retaining textBox values in java  Hi all, i have a jsp screen where i have two actions . I have a single textbox and two buttons. My textbox value is becoming null once i click on any one button. I want the textbox value
Getting Textbox data from database
Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown below. type Exception report message description The server encountered
Javascript
Javascript   Javascript to check Numeric entry in checkbox.....   Hi Please find the following code for numeric entry validation in javascript function validateBox(){ var data=document.myForm.someText.value
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...;head> <script language="javascript" type="text/javascript"> var
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
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 textbox using JSP. <
javaScript
javaScript  . Print a table like below in JAVASCRIPT 5 x 1 = 5 5 x 2 = 10 ΓΆβ?¬Β¦ΓΆβ?¬Β¦ΓΆβ?¬Β¦. 5 x 20 = 100
javascript
javascript  passing javascript values to jsp   Hi Friend, Try the following code: form.jsp: <html> <script> function getMsg...;/script> <input type="button" onclick="getMsg();" value="Get Javascript value
 

 

 

DMCA.com