60 users online (1 members and 59 guests)  


  Results 1 to 9 of 9

Related

  1. Form - checkboxes & file upload    Forum: PHP Forum
    Replies: 1
  2. Checkboxes and arrays    Forum: Javascript Forum
    Replies: 18
  3. php lists and checkboxes    Forum: PHP Forum
    Replies: 2
  4. Buttons and checkboxes    Forum: Javascript Forum
    Replies: 2
  1. #1
    muna's Avatar
    New User

    Status
    Offline
    Join Date
    May 2008
    Posts
    6

    Unhappy delect the selected checkboxes in the table

    hi every one
    i'm new to this platform.i'm having a task regarding the table.in a table all the will be entered into the databse and they will be retrieved to the jsp page and they will be displaying the table in that page in that page we are having the options for the modifying the row of the table and delete.for this option each row will be provided with a check box. down we will be given some options like select all check boxes to delete,none and invert selection of the selected check boxes. i need ur help in the selecting all and selecting none and inverting the selection of the checkboxes.and deleting them could u make it soon

  2. #2
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: delect the selected checkboxes in the table

    A basic example to keep you going
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>check inputs value against array values</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    *{margin:0;padding:0;}
    body{font-family:Verdana,tahoma;font-size:10pt;}
    #items{width:300px;border:3px double #222;margin:20px auto;}
    input{margin-left:5px;margin-right:2px;}
    </style>
    <script type="text/javascript">
    function SetAllCheckBoxes(FormName, AreaID, CheckValue)
    {
    if(!document.forms[FormName])
    return;
    var objCheckBoxes = document.getElementById(AreaID).getElementsByTagName('input');
    if(!objCheckBoxes)
    return;
    var countCheckBoxes = objCheckBoxes.length;
    if(!countCheckBoxes)
    objCheckBoxes.checked = CheckValue;
    else
    for(var i = 0; i < countCheckBoxes; i++)
    objCheckBoxes[i].checked = CheckValue;
    }
    </script>
    </head>
    <body>
    <div id="items">
    <form name="SelectedItems" action="" method="post">
    <div style="background:#ccc;"><input name="checkall" type="checkbox" onclick="SetAllCheckBoxes('SelectedItems','items',this.checked);" />Select/Unselect All</div>
    <br>
    <input type="checkbox" name="selected" value="Some text description 1">Item1<br>
    <input type="checkbox" name="selected" value="Some text description 2">Item2<br>
    <input type="checkbox" name="selected" value="Some text description 3">Item3<br>
    <input type="checkbox" name="selected" value="Some text description 4">Item4<br>
    <input type="checkbox" name="selected" value="Some text description 5">Item5<br>
    <input type="checkbox" name="selected" value="Some text description 6">Item6<br>
    </div>
    </body>
    </html>

  3. #3
    muna's Avatar
    New User

    Status
    Offline
    Join Date
    May 2008
    Posts
    6

    Unhappy Re: delect the selected checkboxes in the table

    tanq ranagna,
    but am not using the checkbox to sellect all the check boxes.im using a radio button to select them (3 options check all,uncheckall,invert selection) when all was selected then it should select all the check boxes when itis checked for uncheck all it should uncheck all the check boxes,and finally it should invert the selection

  4. #4
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: delect the selected checkboxes in the table

    You should have informed me in advance, anyway, here it goes:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>check inputs value against array values</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    *{margin:0;padding:0;}
    body{font-family:Verdana,tahoma;font-size:10pt;}
    #items{width:300px;border:3px double #222;margin:20px auto;}
    input{margin-left:5px;margin-right:2px;}
    #radio{background:#ccc;padding-top:3px;}
    </style>
    <script type="text/javascript">
    window.onload=function()
    {
    var radio=document.getElementById('radio').getElementsByTagName('input');
    radio[0].onclick=function()
    {
    var chks=document.getElementById('checks').getElementsByTagName('input');
    for(var i=0;i<chks.length;i++)
    {chks[i].checked=true;}
    }
    radio[1].onclick=function()
    {
    var chks=document.getElementById('checks').getElementsByTagName('input');
    for(var i=0;i<chks.length;i++)
    {chks[i].checked=false;}
    }
    radio[2].onclick=function()
    {
    var chks=document.getElementById('checks').getElementsByTagName('input');
    for(var i=0;i<chks.length;i++)
    {
    chks[i].checked=(chks[i].checked!=false)?false:true;
    }
    }
    }
    </script>
    </head>
    <body>
    <div id="items">
    <div id="radio">
    <input name="check" type="radio">Check All<br>
    <input type="radio" name="check">Uncheck All<br>
    <input type="radio" name="check">Invert<br>
    </div>
    <br>
    <div id="checks">
    <input type="checkbox" name="selected" value="Some text description 1">Item1<br>
    <input type="checkbox" name="selected" value="Some text description 2">Item2<br>
    <input type="checkbox" name="selected" value="Some text description 3">Item3<br>
    <input type="checkbox" name="selected" value="Some text description 4">Item4<br>
    <input type="checkbox" name="selected" value="Some text description 5">Item5<br>
    <input type="checkbox" name="selected" value="Some text description 6">Item6<br>
    <br>
    </div>
    </div>
    </body>
    </html>
    Hope it helps, BTW, Welcome to the forums

  5. #5
    muna's Avatar
    New User

    Status
    Offline
    Join Date
    May 2008
    Posts
    6

    Re: delect the selected checkboxes in the table

    tanq rangana it is very much helpful to me
    tanx alot

  6. #6
    muna's Avatar
    New User

    Status
    Offline
    Join Date
    May 2008
    Posts
    6

    Re:i need some sort of help regarding the deletion of the row from the database table

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <jsp:directive.page import="java.util.Date"/>
    <jsp:directive.page import="java.sql.Connection"/>
    <jsp:directive.page import="org.sun.DBConnection"/>
    <jsp:directive.page import="java.sql.Statement"/>
    <jsp:directive.page import="java.sql.ResultSet"/>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>


    <title>display of the details uploaded 'table display.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    </head>

    <script language = "Javascript">

    function sel(s,j)
    {
    var i=1;

    if(s=="ALL")
    {
    for(var i=1;i<= j ;i++)
    {
    var sta="chk"+i;

    for (var k=0; k<tabledisplay.elements.length; k++)
    {

    if (tabledisplay.elements[k].name == sta )
    {
    tabledisplay.elements[k].checked = true;

    }
    }
    }
    }

    else
    if(s=="NONE")
    {
    for(var i=1;i<=j ;i++)
    {
    var sta="chk"+i;

    for (var k=0; k<tabledisplay.elements.length; k++)
    {

    if (tabledisplay.elements[k].name == sta )
    {
    tabledisplay.elements[k].checked = false;
    }
    }
    }
    }

    else
    if (s=="TOGGLE")
    {
    for( i=0;i<=j ;i++)
    {
    var sta="chk"+i;
    for (var k=0; k<tabledisplay.elements.length; k++)
    {

    if (tabledisplay.elements[k].name == sta )
    {
    if( tabledisplay.elements[k].checked == false)
    {
    tabledisplay.elements[k].checked = true;
    }
    else
    if( tabledisplay.elements[k].checked == true)
    {
    tabledisplay.elements[k].checked = false;
    }
    }
    }
    }
    }
    }
    </script>
    <body>
    <form name="tabledisplay">

    <%
    DBConnection db = new DBConnection();
    Connection conn = null;
    conn=db.getConnection();
    Statement stmt5=conn.createStatement();
    ResultSet res5=stmt5.executeQuery("select * from sample");
    int i=0;
    String a;
    %>
    <table align="Center" cellpadding="5" cellspacing="3">

    <tr>
    <td><br>
    <b>Sno<br><br></b>
    </td>
    <td><br>
    <b>FirstName<br><br></b>
    </td>
    <td><br>
    <b> LastName<br><br></b>
    </td>
    <td><br>
    <b>dob<br><br></b>
    </td>
    <td><br>
    <b>Gender<br><br></b>
    </td>
    <td valign="middle" align="center"><br>
    <b>Hobbies<br><br></b>
    </td>

    <td><br>
    <b>Modify<br><br></b>
    </td>
    <td>
    <a href="" onclick="delt();"><b>DELETE</b></a>
    </td>
    </tr>

    <%
    int lent=0,j=1;
    while(res5.next())
    {
    j=res5.getRow();
    System.out.println(j);
    %>
    <tr>

    <td>
    <%=res5.getString("sno")%>
    </td>
    <td>
    <%=res5.getString("firstname")%>
    </td>
    <td>
    <%=res5.getString("LastName")%>
    </td>
    <td>
    <%=res5.getString("Dob")%>
    </td>
    <td>
    <%=res5.getString("Gender")%>
    </td>
    <td>
    <%=res5.getString("Hobbies")%>
    </td>

    <td>
    <%String st = "./MyJsp.jsp?id="+res5.getString("sno"); %>
    <a href=<%=st%>>Modify</a>
    </td>
    <td valign="middle" align="center">

    <input type="checkbox" name="chk<%=j%>" id="chk<%=j%>" href="" >
    <%System.out.println("chk"+j);%>
    </td>
    </tr>
    <%
    }

    %>

    </table>
    <table align="center" >
    <br>
    <br>
    <input type="radio" value="ALL" name="rbn" onClick=sel(this.value,<%=j %>)>ALL
    <input type="radio" value="NONE" name="rbn" onClick=sel(this.value,<%=j %>)>NONE
    <input type="radio" value="TOGGLE" name="rbn" onClick=sel(this.value,<%=j %>)>TOGGLE
    </table>
    </form>
    </body>
    </html>

    check box the rows that are selected that row should be deleted from the table plzzz some one plz help me

  7. #7
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: delect the selected checkboxes in the table

    Delete from what table?..in your database?..if so, then JS has no control over it
    ...You should create a new thread in the ASP section.

  8. #8
    muna's Avatar
    New User

    Status
    Offline
    Join Date
    May 2008
    Posts
    6

    Re: delect the selected checkboxes in the table

    thank u rangana i got the solution fo that

  9. #9
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: delect the selected checkboxes in the table

    Glad to hear you sorted it out
    Glad I could help



Tags for this Thread