If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > In clcik of button select all checkboxes and direct to another page

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-23-08, 04:43
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
In clcik of button select all checkboxes and direct to another page

Hi all
I have a asp page in which i am displaying values from database using html table
on click of button all checkboes should be selected and page is directed to another page

<table>
<tr>
<td>
<input type="checkbox" name="some_name" value=<%=rs1("Container_No").Value%>
</td>
<td>
<%=rs1("Container_No").Value%>
</td>
<td>
<%=rs1("Seal_No").value%>
</td>
<td><%=rs1("Origin")%></td>
<td><%=rs1("Arrival_Time")%></td>
</tr>
</table>


Thanks and regards
Ravi
Reply With Quote
  #2 (permalink)  
Old 12-23-08, 05:22
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Does the button submit the form?
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 12-23-08, 05:34
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
Hi
No button does submit the form
on click of button all check boxes should be selected and directed to another page

Thanks
RAvi
Reply With Quote
  #4 (permalink)  
Old 12-23-08, 05:52
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Quote:
Originally Posted by ravisakee
and directed to another page
i.e. submitted?
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 12-23-08, 06:24
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
Hi
On click it will directed to another page
but i am not using any values from the previous page
just i want to select all checkboxes and direct to another page


Thanks
Ravi
Reply With Quote
  #6 (permalink)  
Old 12-23-08, 06:29
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
You can do the checking on client side using JavaScript or...
Code:
<html>
<head>
	<title>Checkbox Checking Check Checker</title>
</head>
<body>

	<%
	Dim selected
	If Request.Querystring("checked") = "true" Then
		checked = "checked='checked'"
	Else
		checked = ""
	End If
	%>

	<form id="main_form" action="do_something.asp" method="post">
		<%
		Dim i
		For i = 0 To 10
		%>

		<input type='checkbox' name='some_name' value='<%=i%>' <%=checked%> />

		<%
		Next
		%>
	</form>

	<form id="checker" action="this_page.asp" method="get">
        <%
		If checked = "" Then
        %>
			<input type='hidden' name='checked' value='true' />
			<input type='submit' value='Check all' />
        <%
		Else
        %>
			<input type='hidden' name='checked' value='false' />
			<input type='submit' value='Uncheck all' />
        <%
		End If
        %>
	</form>

</body>
</html>
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 12-23-08, 07:00
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
hi
how to do it on clent side??
if i have multiple checkboxes i will loop through and check
here i have only one checkbox which will dynamically generate many
how to select all???

Thats my question

Thanks
RAvi
Reply With Quote
  #8 (permalink)  
Old 12-23-08, 08:22
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
The method posted above does it server side. This is a good method because not all people will have JavaScript enabled.

Here's an example in JavaScript
Code:
<html>
<head>
    <title>Checkbox Checking Check Checker</title>
    <script language="JavaScript">
	    function checkThem(check) {
		    for (i=0; i<document.main_form.some_name.length; i++) {
			    document.main_form.some_name[i].checked = check;
		    }
	    }
    </script>
</head>
<body>

    <form name="main_form" action="do_something.asp" method="post">
	    <%
	    Dim i
	    For i = 0 To 10
	    %>

	    <input type='checkbox' name='some_name' value='<%=i%>' <%=checked%> />

	    <%
	    Next
	    %>

        <input type='button' name='CheckAll' value='Check All' onClick='checkThem(true)' />
        <input type='button' name='UncheckAll' value='Uncheck all' onClick='checkThem(false)' />
    </form>

</body>
</html>
__________________
George
Twitter | Blog
Reply With Quote
  #9 (permalink)  
Old 12-23-08, 08:35
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Different spin on the same js method
Code:
<html>
<head>
    <title>Checkbox Checking Check Checker</title>
    <script language="JavaScript">
        function checkUnCheck() {
            var check;
            if (document.main_form.reCheck.value == "Check All") {
                check = true;
                document.main_form.reCheck.value = "Uncheck All";
            }
            else {
                check = false;
                document.main_form.reCheck.value = "Check All";
            }

		    for (i=0; i<document.main_form.some_name.length; i++) {
			    document.main_form.some_name[i].checked = check;
		    }
        }
    </script>
</head>
<body>

    <form name="main_form" action="do_something.asp" method="post">
	    <%
	    Dim i
	    For i = 0 To 10
	    %>

	    <input type='checkbox' name='some_name' value='<%=i%>' <%=checked%> />

	    <%
	    Next
	    %>

        <input type='button' name='reCheck' value='Check All' onClick='checkUnCheck()' />
    </form>

</body>
</html>
__________________
George
Twitter | Blog
Reply With Quote
  #10 (permalink)  
Old 12-23-08, 08:53
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
Hey can i have two events on one button click???
Reply With Quote
  #11 (permalink)  
Old 12-23-08, 08:59
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
You can have a function that calls a function...
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On