Problem to display checkbox item
Hi,
Following is my code:
<%@page import="java.sql.*"%>
<h1>example.jsp</h1>
<table border="1">
<tr>
<td></td>
<th>domainName</th>
</tr>
<%
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()){
%>
<tr>
<td>
<input type="checkbox" name="check"
value=<%= rs.getString("domainId") %>
onClick="if (this.checked) {showState(this.value)()}" value="ON">
</td>
<td><%= rs.getString("domainName") %></td>
</tr>
<%
}
}catch(SQLException e){
System.out.println(e.getMessage());
}
%>
<tr>
<td>
<input type=submit value="submit">
</td>
</tr>
</table>
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.
View Answers
October 20, 2010 at 4:43 PM
Hi Friend,
We have made changes in the code:
1)checkboxExample.jsp:
<%@page import="java.sql.*"%>
<head>
<script>
var xmlHttp;
var arr= new Array() ;
Array.prototype.clean = function(deleteValue) {
for (var i = 0; i < this.length; i++) {
if (this[i] == deleteValue) {
this.splice(i, 1);
i--;
}
}
return this;
};
function showState(){
var total=""
for(var i=0; i < document.form.check.length; i++){
if(document.form.check[i].checked)
arr[i]=document.form.check[i].value;
}
arr.clean(undefined);
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=" +arr;
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>
<form name="form">
<table border="1">
<tr><td></td>
<th>Id</th>
<th>Name</th>
<th>Address</th>
</tr>
<%
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") %> ></td>
<td><%= rs.getString("empid") %></td>
<td><%= rs.getString("name") %></td>
<td><%= rs.getString("address") %></td>
</tr><%
}
}catch(SQLException e){ System.out.println(e.getMessage()); } %>
</table>
<input type="button" value="submit" onClick="showState();">
</form>
<br>
<br>
Selected Data<br>
<div id='sel'>
</div>
October 20, 2010 at 4:44 PM
2) gettable.jsp:
<%@page language="java" import ="java.sql.*" %>
<%
String val[] = request.getParameterValues("val");
String st="";
for(int i=0;i<val.length;i++){
st+=val[i]+"";
}
String str[]=st.split(",");
for(int i=0;i<str.length;i++){
System.out.println(str[i]);
}
ResultSet rs = null;
String buffer="";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
Statement stmt = con.createStatement();
for(int i=0;i<str.length;i++){
String ide=str[i];
int id=Integer.parseInt(ide);
rs = stmt.executeQuery( "SELECT * FROM employee WHERE empid='"+id+"'");
while(rs.next()){
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 6:42 PM
Thank you Deepak for your valuable reply...........:-)
it really works
But,I want some more help from you.
In my program , i have given to link to different jsp pages.
Suppose it contains two links with two different jsp pages.
Both jsp pages contains differents database tables, n it contains same checkboxes.
So, from your above code, i can 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 checkboxes.
So, i want such output, which can show previous pages selected checkbox as well as i aslo include next page's selected checkbox in display list on same pages respectively.( i don't know exactly, but can we store it in session and in collection so that we can display all selected checkbox)
Please,please help me...
waiting for your reply
October 20, 2010 at 7:46 PM
Thank you Deepak for your valuable reply...........:-) it really works
But,I want some more help from you.
In my program , i have given to link to different jsp pages. Suppose it contains two links with two different jsp pages.
Both jsp pages contains differents database tables, n it contains same checkboxes.
So, from your above code, i can 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 checkboxes.
So, i want such output, which can show previous pages selected checkbox as well as i aslo include next page's selected checkbox in display list on same pages respectively.( i don't know exactly, but can we store it in session and in collection so that we can display all selected checkbox)
Please,please help me... waiting for your reply
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:
Problem to display checkbox itemProblem to
display checkbox item Hi,
Following is my code:
<... include next page's selected
checkbox in
display list on same pages respectively.( i... can
display all selected
checkbox)ADS_TO_REPLACE_6
Please,please help me
Adding checkbox to List as item Adding
checkbox to List as
item can we add checkox to List
Hi Friend,
Try the following code:ADS_TO_REPLACE_1
import java.awt....());
CheckListItem
item = (CheckListItem)
list.getModel().getElementAt
Advertisements
Display ProblemDisplay Problem i am creating a small window application , i want to fetch data from ms-access(db) and want to
display it on tables. what options are there to show result on table. is CSS helpfull
Problem with DOJO tree with checkbox - FrameworkProblem with DOJO tree with checkbox Hi Friends,
I have to generate a tree structure in a jsp along with
checkbox besides each node. The tree... opens with tree structure.
The
checkbox will have 3 states: (1) partially
Checkbox pagination problemCheckbox pagination problem HI .,
Following is my code
test.jsp...
Total Selected Domains
" type=
checkbox... not getting it.
when i click on some
checkbox of table"Table Containts" and submit
nested selected tag ihave display selected item nested selected tag ihave
display selected
item i have two combo...="2">UK
etc
in other combo box
display all states relate first combo box, ok it can be done by creating array
my
problem is when i
display data like
iterator display problem - Strutsiterator
display problem
in action class i store database data in arrraylist but after success
how can i
display those data in jsp page using... friend,
Code to help in solving the
problem :
Iterator Tag
Jfreechart chart display problemJfreechart chart
display problem Using JSP and Jfreechart displays the chart fine on an internal browser in eclipse but doesnt
display it on Chrome...(request.getParameter("
q"));
String query="select dateof,dayinprice,company from stockprice
Integer display problemInteger
display problem class Bean{
int n1,n2;
public Bean(){
}
public Bean(int n1, int n2){
this.n1=n1;
this.n2=n2;
}
public...);
}
}
In above program value of n1 should
display 10. But it is displaying 8. what
Problem with display of images in applets - AppletProblem with
display of images in applets Hi all,
When I run... in figuring out the
problem.... Hi frined,
import java.applet.*;
import..., this);
}
}
---------------------------------------
Display image in Java Applet
select Query result display problemselect Query result
display problem Hi,
String SQL_QUERY ="from Cc";
Query query = session.createQuery(SQL_QUERY);
for(Iterator it=query.iterate();it.hasNext();){
Object[] row = (Object[]) it.next
JComboBox Display Problem - Java BeginnersJComboBox
Display Problem I am create one program that contain two combo boxes. If first combo box i am
display all date. If i select one date from first combo box then the second combo box
display some dates based on first
Display values in textbox on selecting checkboxDisplay values in textbox on selecting
checkbox
Here we are going to perform action on selecting the
checkbox and
display the
first five text box values into next five. We have ten text boxes and a
checkbox. As the user enters value
display records with images problem - JSP-Servletdisplay records with images problem hello,
i am developing HR application whereby i want to
display employee records and their pictures on web... with a unique id. Also i wrote i jsp that link to servlet in order to
display checkboxcheckbox how to insert multiple values in database by using
checkbox in jsp
Dojo Tree With Checkbox - Framework structure in a jsp along with
checkbox besides each node. The tree structure... with tree structure.
The
checkbox will have 3 states: (1) partially checked, (2....
and after selecting the values I've to
display those values in the parent page
item lookupitem lookup I need to create a lookup box in a grid that searches and filters at the same time. Upon selection the
item with its price should be displayed. The control would then position below the first selection, so
Item renderer in flexItem renderer in flex Hi.....
I have a
problem
How do you call a method in particular ItemRenderer. Also the ItemRenderer is your own Custom Component?
please give me an example for that......
Thanks
displaydisplay please tell me how to
display the content from database.. if we click on any image using servlets/jsp...please
Item renderer in flexItem renderer in flex Hi.....
How does
item renderer work?
How do I add
item renderer at runtime?
Please me the right answer so i cam implement this in my apps.
Thanks Ans:
The base class for Spark
item Maintain checked checkbox statusMaintain checked
checkbox status Hi everyone
In my JSP application, i have database table stored in mysql. when i
display there recors using...
display that "selected checked checkboxes" in same page but in another table
Checkbox methodCheckbox method what is the method to check if the
checkbox is checked
JSP CheckBox
JSP
CheckBox
JSP
CheckBox is used to create a
CheckBox in JSP...
checkbox and also print the
userdefined message that specify the languages option
return item in jqueryreturn
item in jquery How to return items/variables in JQuery?
See the code below to find out how to return an
Item in Jquery:
function findItem() {
var
item;
while(if_
item_not_found) {
// search
ModuleNotFoundError: No module named 'item'ModuleNotFoundError: No module named '
item' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
item'
How to remove the ModuleNotFoundError: No module named '
item' error
Checkbox blocked - WebSevicesCheckbox blocked Hi,
i design online ticket reservation for bus. It contains no of seats. if i choose 3 or 4 seats
checkbox,it will stored in my database. After i refreshing the page that
checkbox seats are blocked
UIButton checkboxUIButton checkbox iPhone UIButton
checkbox example required.. can any one please explain me.. how to create a
checkbox button using UIButton in XIB
Item renderer in flexItem renderer in flex Hi......
please tell me about
How to create
item renderers in flex?
give an example for that
Thanks
Checkbox
Checkbox
A
checkbox is again a label which is displayed
as a pushbutton as shown in the example... of the
checkbox is
either true or false. However, the initial state is false
navigation item back buttonnavigation
item back button I wants to add a navigationBar on the top of my UIWebView also a navigation
item "back button". can anyone please explain how the back and refresh button works
Ajax CheckboxAjax Checkbox I want ajax code for checkboxes.The scenario is that if a selectbox is selected the corresponding values to it in the database table are to be checked in the
checkbox.....Please do help me
Item renderer in flexItem renderer in flex Hi...
Please tell me about
what does listData contain in ItemRenderers? What is the Type of listData?
please give an example for that........
Thanks
highlight menu item htmlhighlight menu
item html highlight menu
item in html or CSS
<body id="index">
<div id="menu">
<ul>
<li class="index" ><a href="index.html">Index page</a></li>
<
CheckBox in Flex a particular
CheckBox item.
<mx:CheckBox> tag is use to access...Flex
CheckBox Control:
The
CheckBox control of Flex is a very common GUI, which is supported by almost every computer language.
CheckBox control is used when
JavaScript Checkbox getElementById
JavaScript
Checkbox getElementById...() for
checkbox in JavaScript.
In the given example we are going to show an image on clicking the
checkbox.
This is done by using the JavaScript method getElementById
Display TagDisplay Tag Hi
Here is My code,
There is
problem At line no.3, where i want to
display two fields in one column but it gives error..
Please any one knows the solution must reply
Thanks In Advance
Display TagDisplay Tag Hi
Here is My code,
There is
problem At line no.3, where i want to
display two fields in one column but it gives error..
Please any one knows the solution must reply
Thanks In Advance