View Full Version : checkbox or radio button value cant keep during recordset paging function
cloudy
01-24-2008, 03:18 PM
hi everybody. i got a list of checkboxes and radio button with the recorset paging function. let said i got the paging list << 1 2 3 4 5 >>. i set each page is 10 records. and every record got one checkbox for DELETE ID usage. in the first page, i check 5records, then i go to second page, i checked another 5records. but why it cant keep the value for the first page 5records when i go back or go to next pages? hope u all can give me some solution on it.plz help..thank you.
abduraooft
01-24-2008, 03:24 PM
I don't think it's possible by some simple logic, since each time when you click on a page it will get reloaded and the previous selection will be lost. The best way is to use delete from each page based on the selections there.
cloudy
01-24-2008, 03:47 PM
i wan to do something same like the yahoo mail box, it can keep the user email address from every pages..
angst
01-25-2008, 03:48 PM
well, you could use a session object to gather the data each time you click a checkbox via Ajax. that would be fairly simple.
cloudy
01-25-2008, 03:53 PM
halo angst , can u tell me more? or got any refernce page to intro me? plz help...plz guide me how to start the coding..thanx
angst
01-25-2008, 04:22 PM
try this:
<%
strAction = request("action")
If strAction = "AddSession" Then
Session("RecordID") = Session("RecordID") & request("SessionValue") & ","
ElseIf strAction = "GetSessionValues" Then
response.write Session("RecordID")
Else
%>
<script>
// create http request object
function GetXmlHttpObject() {
var xmlHttp = null;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
xmlHttp = new XMLHttpRequest();
if (xmlHttp.overrideMimeType) xmlHttp.overrideMimeType('text/xml');
} else if (window.ActiveXObject) { // IE
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert ("Browser does not support HTTP Request")
return false;
}
}
}
return xmlHttp;
}
// add to session
function SetSession(numRecordID){
var xmlHttp;
xmlHttp=GetXmlHttpObject();
if (!xmlHttp) return false;
var url="index.asp"
url=url+"?action=AddSession&SessionValue=" + numRecordID;
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
GetSession();
}
// get results
function GetSession(){
var xmlHttp;
xmlHttp=GetXmlHttpObject();
if (!xmlHttp) return false;
var url="index.asp"
url=url+"?action=GetSessionValues";
xmlHttp.onreadystatechange=function() { DisplayResults( xmlHttp ); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
// display results
function DisplayResults( xmlHttp ){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
var HTMLResponse = xmlHttp.responseText;
document.getElementById("SessionResult").innerHTML = HTMLResponse;
}
}
</script>
<h1>Checkbox Ajax Test</h1><br />
<div id='SessionResult' name='SessionResult'></div><Br />
<%
x = 0
Do Until x = 10
x = x + 1
response.write "<input type='checkbox' onClick=""SetSession(" & x & ");"" /><br />" & vbNewLine
Loop
Session("RecordID") = ""
End If
%>
just make a new page and call it index.asp and run it. then try clicking on the checkboxes.
cloudy
01-25-2008, 04:47 PM
halo angst , soli ...i m not understand.
angst
01-25-2008, 04:49 PM
just copy and past that code into a new page called "index.asp" and run the page.
then you can see it work, and play with the code.
cloudy
01-25-2008, 04:52 PM
but i jz cant see anything after i check the checkbox..??
angst
01-25-2008, 05:10 PM
ah, what browser are you running? and are you running this on an asp enabled server? also are you getting any JS errors when you click the checkbox?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.