Jump to content

Working With Checkbox On Asp


juxdoit

Recommended Posts

Hi,Need some help and advise here.I got a few number of checkboxes in my ASP web application.I am wondering how am i able to capture the value of the checkbox whenever i tick the checkbox?------------------------------------------<form method="post" ACTION="<%=Request.ServerVariables("PATH_INFO")%>" Name="formDeleteFile"><%For i = 1 to counter%> <input type="checkbox" value="<%=counter%>" name="<%=counter%>">next<input class="submitbutton" type="submit" name="filesDelete" value="Delete File"></form>*i want to capture the value of each checkbox i have ticked when button is press*if Request.Form("filesDelete") > "" thenend if------------------------------------------appreciated any help and advice ~ thanks in advance ...

Link to comment
Share on other sites

One quick test that I'd try is to view the resultant HTML so that you can check that the boxes each have unique names before you can view the values in the code.

Link to comment
Share on other sites

One quick test that I'd try is to view the resultant HTML so that you can check that the boxes each have unique names before you can view the values in the code.
I managed to capture the values of each checkbox i checked but i got problem which i am unable to solve. I am doing a multiple deletion of my filesystemobject using the asp. It seem that my coding only able to delete the first one i tick (when i do multiple tick of checkbox).Can anyone help to solve this problem or got any good reference for me to go through? below is my coding...------------------------------------------------------------------------------------<%function returnGetFolder(fileRoot) dim folderPath if fileRoot = 1 then folderPath = "http://intranet/fileAccess/HR/folderA/" elseif fileRoot = 2 then folderPath = "http://intranet/fileAccess/HR/folderB/" elseif fileRoot = 3 then folderPath = "http://intranet/fileAccess/HR/folderC/" elseif fileRoot = 4 then folderPath = "http://intranet/fileAccess/HR/folderD/" end if returnGetFolder = folderPathend function%><Form METHOD="post" ACTION="<%=Request.ServerVariables("PATH_INFO")%>?file_root=<%=fileRoot%>&dept=<%=dept%>" Name="formDeleteFile"><%Dim objFSO, objFile, objFolder, fileCounterSet objFSO = Server.CreateObject("Scripting.FileSystemObject")Set objFolder = objFSO.GetFolder(Server.MapPath(returnGetFolder(fileRoot)))response.write "<table>"For each objFile in objFolder.Files fileCounter = leftCounter + 1 Response.Write "<tr>" Response.Write "<td>" & returnExtIcon(objFSO.GetExtensionName(objFile.Name)) & "</td>" Response.write "<td>"%> <input type="checkbox" value="D:\Project\intranet\<%=replace(returnGetFolder(fileRoot)&objFile.Name,"/","\")%>" name="delCB"><% Response.write "</td>" Response.write "</tr>"NextResponse.write "<tr><td>"Response.write "<input class=submitbutton type=submit name=filesDelete value='Delete File'>"Response.write "</td></tr>"response.write "</table>"....................Dim checkedValue, mulCheckedValue, rsMulCheckedValue, loopValueif Request.Form("filesDelete") > "" then checkedValue = Request.Form("delCB") mulCheckedValue = split(checkedValue,",") for loopValue = LBound(mulCheckedValue ) to UBound(mulCheckedValue ) objFSO.DeleteFile(mulCheckedValue(loopValue)) nextend ifset objFSO = nothing%>----------------------------------------the error is as below and line 287 refer to "objFSO.DeleteFile(rsMulCheckedLValue(loopValue))"it display the below error immediately after i press delete. and when i go back to view the file, i saw the first one of the checkbox was deleted and the rest still there.-----------------------------------------Technical Information (for support personnel)Error Type:Microsoft VBScript runtime (0x800A0034)Bad file name or number/intranet/filesDelete.asp, line 287Browser Type:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Page:POST 214 bytes to /intranet/filesDelete.aspPOST Data:delCB=D%3A%5CProject%5Cintranet%5CHR%5CFolderA%5CDesign_Media.pdf&delCB=D%3A%5CProject%5Cintranet%5CHR%5CFolderA%5CMS_ITPRO_FT.pdf&filesDele . . . can anyone advise?
Link to comment
Share on other sites

One thing that I'd do is to have the file deletion in a custom sub or function. I'd first build a loop to check the status of each box in turn and then if it was checked call the aforementioned sub/function to perform the deletion.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...