display checked ckeckbox in same jsp page

display checked ckeckbox in same jsp page

how to display checked ckeckbox in same jsp page?

View Answers

October 20, 2010 at 11:46 AM

Hi,

Here is the html code to display check box:

<html>
<head>
<title>Test Page</title>
</head>
<body>


<form method="post">
<p>Check box:<input name="Checkbox1" type="checkbox">
</p>
</form>
</body>

</html>

Please let's know if you any other query.

Thanks


October 20, 2010 at 11:54 AM

Thanks deepak for your reply. But I havw database store in server. From that database, i have displayed all values with checkbox in one table.

Now i want to display ,selected checked checkboxes in another table in same jsp page.

(for example, as it happens in VB that after clicking checkbox and submitting it goes to another table ...dynamically)

All it shoud happen dynamically.

Please help me.


October 20, 2010 at 12:27 PM

Hi,

You may use the jqgrid

Please check the demo at jqgrid website.

You can use its Subgrid module. This module will allow you to crate grid and subgrids.

See it at http://www.trirand.com/blog/?page_id=6

Regards Deepak Kumar


October 20, 2010 at 12:50 PM

Thanks deepak for your reply.

But, instead of using other grid modules, can it be possible with help of java code or jsp or html ....

Please help me.


October 20, 2010 at 12:54 PM

Hi Friend,

Try the following code:

checkboxExample.jsp:

<%@page import="java.sql.*"%>
<head>  
 <script>  
 var xmlHttp  

 function showState(id){ 
 if(typeof XMLHttpRequest != "undefined"){
   xmlHttp= new XMLHttpRequest();
   }
   else if (window.ActiveXObject){
   xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
   }
 if (xmlHttp==null){
    alert ("Browser does not support XMLHTTP Request")
 return
} 
var url= "gettable.jsp";
url += "?val=" +id;
xmlHttp.onreadystatechange = stateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
 }
 function stateChange(){   
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){   
 document.getElementById("sel").innerHTML=xmlHttp.responseText;
  }
 }   


  </script>  
 </head>

<table border="1">
<tr><td></td>
<th>Id</th>
<th>Name</th>
<th>Address</th>
</tr>
<%
int i=0;
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
rs = st.executeQuery("select * from employee");
 while(rs.next()){ %>
<tr><td><input type="checkbox" name="check" value=<%= rs.getString("empid") %> onClick="if (this.checked) {showState(this.value)()}" value="ON"></td>
<td><%= rs.getString("empid") %></td>
<td><%= rs.getString("name") %></td>
<td><%= rs.getString("address") %></td>
</tr><%
i++;
}
}catch(SQLException e){ System.out.println(e.getMessage()); } %>
</table>
<br>
<br>
Selected Data<br>
<div id='sel'>  

 </div>

October 20, 2010 at 12:55 PM

continue..

gettable.jsp:

<%@page language="java" import ="java.sql.*" %>  
 <%  
String val = request.getParameter("val").toString();
int id=Integer.parseInt(val);
 String buffer="";  
 Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery( "SELECT * FROM employee WHERE empid='"+id+"'");  
   while(rs.next()){
       String name=rs.getString(2);
   buffer=buffer+"<table border><tr><td>"+rs.getString("empid")+"</td><td>"+rs.getString("name")+"</td><td>"+rs.getString("address")+"</td></tr></table>"; 

   }  
 response.getWriter().println(buffer);  
 %>

Thanks


October 20, 2010 at 2:56 PM

Deepak,....Thanks for your valuable reply

your code works properly. But when i made some changes according to my need, i am getting problem.

I am sending you .jsp file

<%@page import="java.sql.*"%>

<% try{ Connection conn = null; Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/entity","root", "rahul"); ResultSet rs = null; Statement st=null; st=conn.createStatement(); rs = st.executeQuery("select * from domain where categoryId=1"); while(rs.next()){ %> <% } }catch(SQLException e){ System.out.println(e.getMessage()); } %>
domainName
onClick="if (this.checked) {showState(this.value)()}" value="ON"> <%= rs.getString("domainName") %>

I want to display records, when i click on submit button or any dumy button like submit.

for your info. In above code, it contains,

"domain" table containg three columns.

domainId--as number domainName--as string categoryId--as number

Plese, help me.


October 20, 2010 at 2:56 PM

Deepak,....Thanks for your valuable reply

your code works properly. But when i made some changes according to my need, i am getting problem.

I am sending you .jsp file

<%@page import="java.sql.*"%>

<% try{ Connection conn = null; Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/entity","root", "rahul"); ResultSet rs = null; Statement st=null; st=conn.createStatement(); rs = st.executeQuery("select * from domain where categoryId=1"); while(rs.next()){ %> <% } }catch(SQLException e){ System.out.println(e.getMessage()); } %>
domainName
onClick="if (this.checked) {showState(this.value)()}" value="ON"> <%= rs.getString("domainName") %>

I want to display records, when i click on submit button or any dumy button like submit.

for your info. In above code, it contains,

"domain" table containg three columns.

domainId--as number domainName--as string categoryId--as number

Plese, help me.


October 20, 2010 at 4:02 PM

Thank you for your valuable reply, but i code which you have sent above...

i want select multiple checkbox at a time and on click of button it should disply all selected checkbox details.....

please, how to modify in above code.. please, help me.I am new to jsp & java


October 21, 2010 at 11:46 AM

Hey please, help me.. i am new in java and jsp

please, send me modified code

waiting your reply









Related Tutorials/Questions & Answers:
display checked ckeckbox in same jsp page
display checked ckeckbox in same jsp page  how to display checked ckeckbox in same jsp page?   Hi, Here is the html code to display check..._TO_REPLACE_2 Now i want to display ,selected checked checkboxes in another table in same
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
Advertisements
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
how to use dropdown list in JSP and display value in same page
how to use dropdown list in JSP and display value in same page  I... in the same page Value selected = C How can we do this in a JSP page... one option the value must get displayed below it in the same page
add same tables in jsp page
add same tables in jsp page  hi I have a table in my jsp page with data, now I want to add same copy of table without its default value in same page whenever I click add more table, how do I do
Show image and text on same jsp page
Show image and text on same jsp page  Hi all, I have to display image and text on the same jsp page. The text and image are both retrived from mysql database. The image is shown correctly on seperate jsp page but when shown
display contents on the same page by selecting a radio button
display contents on the same page by selecting a radio button  Bill Amount Rs.<input type="text" name="amm"/> Bill Status: Pending<... on the same page under the radio button
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
Displaying checked checkbox in same page as well as print on another page ....also add next pages cheches checkbox into previous list
Displaying checked checkbox in same page as well as print on another page... display selected checkbox on same page. It works... But when i go to another page link containing same format, it does not display previous page's selected
Jsp-delete checked checkboxes and display UNCHECKED checkboxes in table as well as in store that unchecked checkboxes in ARRAYLIST
Jsp-delete checked checkboxes and display UNCHECKED checkboxes in table as well... clicked on DELETE button, it should delete records of checked checkbox rows. I need to delete all the table rows which contain CHECKED textboxes.and remaining
How to display content in same page while selecting fron dropdown list
How to display content in same page while selecting fron dropdown list ...),then it want to display all records from table specific to that rollno in that same... at the JSP page will be interpreted by the browser, first. You can use Javascript
Redirect to same jsp page on successful login
Redirect to same jsp page on successful login  Hi, I have an application where on successful login, the redirect should happen to same page... from the database. I am unable to create the session for the same login page
staying in same page after deliting arow in jsp page - JSP-Servlet
staying in same page after deliting arow in jsp page  Hello Sir, I want to stay back in current jsp page after deleting row in jsp table. how can..., As per your problem visit this link..... http://www.roseindia.net/jsp
How to display content in same page while selecting fron dropdown list
How to display content in same page while selecting fron dropdown list  Thanks for your suggesstion.but Please provide me coding by using only one dropdownlist in javascript or jquery.Thanks in advance
Get form value in same page - JSP-Servlet
Get form value in same page  Hello friends, Can we get a form field value in the same to be processed in java coding... friend, For solving the problem visit to : http://roseindia.net/jsp/user
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE ... SystemAdmin 2 Office Bearer Am loading this Rolename into one page called... is how to get Roleid in textbox when i select Role_name from combobox in a same
search an element in arraylist and display in jsp page
search an element in arraylist and display in jsp page  Hello Can anyone help how to take input from user from a jsp page to search for a substing in arraylist in java class and display the list in jsp page Thanks
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
How to Display jrxml file on JSP page???
How to Display jrxml file on JSP page???  I made jrxml file using jasper report but how to display on jsp page?? i tried lot but still i didnt find out solution.so pls help me as soon as possible
using ajax and jsp (struts) to login and remain on same page.
using ajax and jsp (struts) to login and remain on same page.  I am... want to remain on same login page and just want to display loggers name ... I don't know how to use struts to remain on same page. What about config file:- <
How to browse and upload the file in same page using jsp.
How to browse and upload the file in same page using jsp.  Hi Sir, I am doing a project in jsp servlets and i want to browse and upload the file in cell if a table in same page, post answer as soon as possible.thanks
How to browse and upload the file in same page using jsp.
How to browse and upload the file in same page using jsp.  Hi, I am doing a project and i want to browse and upload the file in same page inside.... Regards, Santhosh.   Here is a jsp upload file application. The given code
Request header display in a jsp page
Request header display in a jsp page  ... to display request header information in a jsp page. When user request... to a jsp. In this example, request_header_jsp.jsp is used to display header
Servlets errors in same page.
Servlets errors in same page.  How do I display errors list in the same page where a form field exists using servlets...........i.e. without using JSP? Please explain with a simple username password program
display 10 records per page in jsp - JSP-Servlet
display 10 records per page in jsp  hello, can i get a code that displays 10 records per page from a table student and when i click on the next...: pagination.jsp: Pagination of JSP page Roll No Name Marks
to bring checked data from one page to another
to bring checked data from one page to another  thanks for your help... there is one jsp page , on it there is a link, on click of which it is opening second jsp page which is connected with servlet at the back and through which i am
I want to display 10,000 records in a jsp page.Can I display page by page?
I want to display 10,000 records in a jsp page.Can I display page by page? ... print page by page or have say 900 records per page in a jsp? Should I have to write a for loop in the output.jsp page? Please help me with this requirement
how to display image and text in single jsp page from the mysql database
how to display image and text in single jsp page from the mysql database  hello please help me to display the image and text in single jsp page from mysql database if have any reference code please send me Thanks in advance
How to display Jfreechart from servlet in jsp web page at specified location
How to display Jfreechart from servlet in jsp web page at specified... to display the chart in web page. I generated the chart using Jfreechart... in jsp web page . Thank you very much Sir
how to display each arraylist value on new page in jsp
how to display each arraylist value on new page in jsp  hi!!!! i want to display each arraylist value on new page in jsp????? and also want to access...://www.roseindia.net/jsp/servlet-jsp-data-list.shtml
How to read and display data from a .properties file from a jsp page
How to read and display data from a .properties file from a jsp page  I have a .properties file. I have to create a jsp page such that it reads... = DEDCHGG_PWDP and goes on... I have to create a jsp page to show these data
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
open pdf file in same jsp page and the pdf file should retrieved from database
open pdf file in same jsp page and the pdf file should retrieved from database  Hai all, I need code to open a pdf file in same jsp page(browser) while click on hyperlink And the file was located in database table. Can any
code to display 20 record per page and display page 1,2,3,4 as recoerd increase - JSP-Servlet
code to display 20 record per page and display page 1,2,3,4 as recoerd increase  Here is my code i wnat to diplay 15 to 20 records per page please... and previous button or display page no 1,2,3.. this is my code please any one
Display image on JSP page using XML
Display image on JSP page using XML  ... can display a image on JSP page by using XML.  This example will examine how to parse and expose XML information using the JAXP with a JSP page
pre Page load display an image loading - JSP-Servlet
pre Page load display an image loading  hi, We have requirement...;Hi Friend, Do you want to display image before loading page? Please clarify this. Thanks  Yes i have to display an loading image while page
How to display date in JSP?
How to display date in JSP?  How to create a simple JSP program which displays date on the page? Thanks
login for different user in the same page
login for different user in the same page  how can i do the login for different user in the same page throug jsp
How to display a record containing 30 fields in jsp without scrolling the page horizontally?
How to display a record containing 30 fields in jsp without scrolling the page horizontally?  I want to display records containing 30 fields in a table row.Is it possible in jsp without scrolling the page horizontally
populating a screen on the same page
populating a screen on the same page  i'm making a time table in jsp... to a new page which will help them to choose the subject and faculty through drop... to select the subject and faculty....so that we dont need to redirect to other page
JSP - Checkbox remain checked although checked values should depend on values stored in a stateful session bean
JSP - Checkbox remain checked although checked values should depend on values.... There are 3 JSP pages, shop1.jsp , shop2.jsp and shop3.jsp where each of these pages have different items to choose from. And there is another page final.jsp which
Maintain checked checkbox status
display that "selected checked checkboxes" in same page but in another table. and at same time, after "Refreshing " that page or after coming to that page...Maintain checked checkbox status  Hi everyone In my JSP
how read data from doc file in same formate in jsp
how read data from doc file in same formate in jsp  how we can read and display data on jsp page, from doc file with the same formatting
Want to display Arraylist items on same row in JSF
Want to display Arraylist items on same row in JSF  I want do display values of one arraylist on same row using datatable? If i use h:column, then it goes on different row. Please tell me, how I can do it?   Hi Friend
How to display date in JSP?
How to display date in JSP?  How to create a simple JSP program which displays date on the page? Thanks   Hi, You should import...() %> Check complete tutorial at How to Create JSP Page? Thanks
Display JSP selected listbox and checkbox in xml-please help me
first page ,it will stored in XML file and at same time ,it should display second... selected listbox from first page. Same with second jsp page.ADS_TO_REPLACE_2 So we...Display JSP selected listbox and checkbox in xml-please help me  Hi

Ads