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



Home Answers Viewqa JSP-Servlet display checked ckeckbox in same jsp page
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


rahul
display checked ckeckbox in same jsp page
10 Answer(s)      4 years and 4 months ago
Posted in : JSP-Servlet


how to display checked ckeckbox in same jsp page?


Advertisement
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... ,selected checked checkboxes in another table in same jsp page. (for example
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
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... page's selected checkbox in display list on same pages respectively.( i don't... same checkboxes. So, from your above code, i can display selected checkbox on same
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 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
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
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
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
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
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
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
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
Advertisements
 

 

 

DMCA.com