473,385 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Remove contact number from textbox on unchecking the checkbox

Expand|Select|Wrap|Line Numbers
  1. package com.List.doc;
  2.  
  3. import java.io.*;
  4. import javax.servlet.*;
  5. import java.sql.*;
  6. import javax.servlet.http.*;
  7. public class ShowDocList extends HttpServlet {
  8.  
  9. public void service(HttpServletRequest request, HttpServletResponse response)
  10.             throws ServletException, IOException {
  11.         response.setContentType("text/html;charset=UTF-8");
  12.         PrintWriter out = response.getWriter();
  13.         String docArea = request.getParameter("doc");
  14.         //out.println("Ärea="+docArea);
  15.         //out.println("<center><table border=1>");
  16.         Connection con=null;
  17.         String sql;
  18.         try
  19.         {
  20.            Class.forName("oracle.jdbc.driver.OracleDriver");
  21.            con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","chauhan");
  22.            if(docArea.equals("All Districts"))
  23.                sql="select * from docdata";
  24.            else
  25.                sql="select name,id from DocData where district='"+docArea+"'";
  26.            Statement st=con.createStatement();
  27.            ResultSet rs = st.executeQuery(sql);
  28.            int i=0;
  29.            String[] array= new String[100];
  30.            out.println("<html><head>"
  31.                    + "<script type=\"text/javascript\">  \n"
  32.                    + "function remove() {  \n "
  33.                    + "var aObj=document.getElementsByTagName('tbody')[0].getElementsByTagName('tr');  \n "
  34.                    + "var i=aObj.length;   \n "
  35.                    + "var unchecked = [];  \n "
  36.                    + "while(i--) {  \n "
  37.                    + "var box =aObj[i].getElementsByTagName('input')[0];   \n "
  38.                    + "if(box.checked==0) {  \n "
  39.                    + "aObj[i].parentNode.removeChild(aObj[i]);  \n "
  40.                    + "}  \n "
  41.                    + "else {  \n "
  42.                    + "\n "
  43.                    + "unchecked.push(box.value);\n "
  44.                    + "\n "
  45.                    + "}  \n "
  46.                    + "}  \n "
  47.                    + "}  \n "
  48.                    + "</script>"
  49.                    );////closing of javascript
  50.            out.println("<table align=center border=1>");
  51.            while(rs.next())
  52.            {
  53.                String id=rs.getString("id");
  54.                //out.println(id);
  55.                //out.println();
  56.                out.println("<tr><td><label><input type=checkbox>"+rs.getString("name")+"</label></td></tr></textarea>");
  57.                    String sql2="select contact from DocData where id='"+id+"'";
  58.                    Statement st2=con.createStatement();
  59.                    ResultSet rs2 = st2.executeQuery(sql2);
  60.                    while(rs2.next())
  61.                     {
  62.  
  63.                         //for(;i<=i;i++)
  64.                             array[i]=rs2.getString("contact");
  65.                             i++;
  66.                         //out.println("<table align=left><tr><td>"+array+"</td></tr></table>");
  67.                     }
  68.                         }
  69.            out.println("<textarea>");
  70.            for(int j=0;j<i;j++)//loop to display contact numbers.
  71.            {
  72.                out.println(array[j]);
  73.            }
  74.            out.println("</textarea>");
  75.           }
  76.           catch(Exception e)
  77.          {
  78.              e.printStackTrace();
  79.          }
  80.         //out.println("</textarea>");
  81.         out.println("<button type=button onclick=remove();>Show final list</button>");
  82.     }
  83. }
  84.  
  85.  

By executing the above code it will display contact numbers with correspondent Names with check box & if we check on any name & then press "Show Final List" button then it will remove all unchecked names. But don't remove Contact Numbers of the correspondent name. please help to remove the contact number also and code to show these contact numbers on other web page.
May 27 '14 #1
1 1578
mHealth
13
On Unchecking the contact box, set text corresponding to "contact number" as "" programatically.
Jun 8 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Henry | last post by:
How to know if a click is on a DataGridTextBoxColumn or DataGridBoolBoxColumn in a datagrid? How to use dataview.ListChanged event to catch the content change for a textbox and/or checkbox? ...
2
by: MalteseFalcon | last post by:
Hello I am trying to remove the caret (i.e. the blinking bar) from a textbox. Anyone knows the trick to do this please? Thanks and Regards J -- Before God we are equally wise and equally...
2
by: Peter | last post by:
I hate using the mask edit conrol so I created these two function to format my phone numbers. Is there a way to consolidate these two functions into one? In this example say the textbox you...
2
by: Becker | last post by:
This is probably a very dumb question, I am using VB.NET 2003 and I see where I can use a method to append text to a textbox, but how about remove? I have a textbox that I continually post log type...
1
by: Ramakrishnan Nagarajan | last post by:
Hi, I have two checkboxes in each row of a grid. One for Modify and another one for View. If I click Modify the View should get automatically checked and should be disabled. Earlier I did this in...
1
by: bird | last post by:
Greetings, I'm trying to calculate the total on an php page. I'm able to get the checkbox portion to work properly but I'm having trouble with the textbox "txtshipping". The default is 7.95...
1
by: Luzuko | last post by:
I would like to know how can i restrict textbox input in VB.net using code instead of VB.net controls. e.g If i want a user to type numbers only in a textbox(ID number textbox), how can i make...
2
by: Henry J. | last post by:
I'm DB2 newbie. I need to remove large number of rows from a table. I don't want to fill up the transaction log space. I have the below SQL that I feed to the db2 command to repeatly remove a...
5
by: Henry J. | last post by:
I'm new to DB2. I want to remove large number of rows in a table without filling up the transaction log space. To this end we can repeatedly remove a fixed number of rows followed by commit. In...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.