troubleshooting Question

Need help with ASP responce.write checkbox name

Avatar of Thomas Grassi
Thomas GrassiFlag for United States of America asked on
ASPWeb Development
12 Comments1 Solution316 ViewsLast Modified:
ASP classic

I had two pages that displayed information by using my file system folders and sub folders.
All this information also is in a SQL database. So I decided to use the SQL database records for my selections and queries.
This makes it easier for my to write sql queries than to try and use the file system.

Also using ajax and json to help build a better page display.

The page I am working on builds a list which has checkbox so the user can select the items they wish to see.
Once checked then hit the submit button and the new page presents a list of the selected items

That's the part I am having trouble with at this time I am getting a blank page

The original method produces a very long list and that's is what I wanted to change so I used ajax and json with several js and css codes.

So I have the test pages almost working.

here is the site to check out the original pages and the new pages.

The original pages

You will see a very long list 8232 records
If you select any and click on submit it takes you to

That is the display I am trying to get to with my new code.

The new code

I am only displaying top 50 records for testing

If you check any of the records and click on submit you will see what I am talking about.

The code for the new page is here

<!DOCTYPE html>
<link href="css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.11.0.min.js"></script>
<script src="js/jquery.dataTables.js"></script>

    $(document).ready(function() {
    $('#example').dataTable( {
        "ajax": 'MusicAJson.asp',
         "deferRender": true
    } );
} )
  <meta charset="utf-8">
<form name="input" action="SelectAlbums.asp" method="post">
<table id="example" class="display" cellspacing="0" width="100%">
                <th>Artist Name</th>
                <th>Recording Title</th>
                <th>Artist Name</th>
                <th>Recording Title</th>
    <button type="submit">Submit</button>  <input type="button" value="BACK!"onClick="history.back();">

You can see the above uses this

<%Response.Buffer = false%>
<!-- #include file="" --> 
{"data": [

Set oConn=Server.CreateObject("ADODB.Connection") 
oConn.Open strConnect
strSQL1 = "set rowcount 50 SELECT artists.ArtistName, Recordings.RecordingTitle FROM dbo.Artists AS artists INNER JOIN dbo.Recordings AS Recordings ON artists.ArtistID = Recordings.ArtistID UNION ALL SELECT artists.ArtistName, NULL RecordingTitle FROM dbo.Artists AS artists ORDER BY ArtistName, RecordingTitle "
Set oRs1=oConn.Execute(strSQL1,lngRecs,1)

' send data to an array'
if not oRs1.eof then
end if

Set oRs1 = Nothing
Set oConn = Nothing

for r = LBound (myArray,2) to UBound(myArray,2)
	    artistname 		= myArray(0, r)
	    RecordingTitle 	= myArray(1, r)
        ' <input type="checkbox" value="link">Link
	    RecordingTitleCheckBox = "<input type="&"[x]"&"checkbox"&"[x]"&"  name="&"[x]"&"track_title"&"[x]"&" type="&"[x]"&"value="&"[x]"&RecordingTitle&"[x]"&">"&RecordingTitle
	    theRow =  replace("["&chr(34)&artistname&chr(34)&","&chr(34)&RecordingTitleCheckBox&chr(34)&"]","\","\\")
	    theRow = replace(theRow,"[x]","\"&chr(34))
	    response.write theRow
        if r < UBound(myArray,2) then
    	response.write ","
    end if

The code on lines 22 to 35 is what I need help on

The uses selectalbums.asp    
selectablums.asp is expecting "CHKALBUM" to be passed to it

Here is selectalbums.asp

<!-- #include file="" -->
dim searchWord, searchIN
dim strFont1
dim strFont2
searchIN = ""


searchWord = Request.form("chkAlbum") 'change form to method post 

if searchWord <> "" then
arrSearchWord = split(searchWord,",") ' convert to array'
for each phrase in arrSearchWord
    searchIN=searchIN & "'" & Trim( phrase ) & "'," 
searchIN=left(searchIN,len(searchIN)-1) ' remove the last comma'

strFont1 = "<font style=""font-size: 20px; color: #ff0000; font-family:verdana"">"
strFont2 = "<font style=""font-size: 16px; color: #000000; font-family:verdana"">"

Set oConn=Server.CreateObject("ADODB.Connection") 
oConn.Open strConnect
strSQL1 = "SELECT dbo.Artists.artistname, dbo.Recordings.RecordingTitle, dbo.Tracks.TrackTitle, dbo.Tracks.TrackFileName FROM  dbo.Artists INNER JOIN dbo.Recordings ON dbo.Artists.artistid = dbo.Recordings.ArtistID INNER JOIN dbo.Tracks ON dbo.Recordings.RecordingID = dbo.Tracks.RecordingID WHERE     (dbo.Artists.artistname IN ("&searchIN&") or (dbo.Recordings.recordingtitle IN ("&searchIN&")))"

Set oRs1=oConn.Execute(strSQL1,lngRecs,1)
if not oRs1.eof then
end if

end if


<form method="post" action="music3.asp">

Response.Write strFont1 & "Select Songs you Wish to Add to Your Playlist then click on Submit button<br />"
Response.Write "<br />"

if goodData =1 then
   For r = LBound(arrResults, 2) To UBound(arrResults, 2)
   		artistname		= arrResults(0,r)
   		RecordingTitle	= arrResults(1,r)
   		TrackTitle		= arrResults(2,r)
   		TrackFileName	= arrResults(3,r)
       	response.write strFont2 & "<div class=""results""><input type=""checkbox"" name=""selectItem"" value="""&TrackFileName&"""> "&artistname&" "&RecordingTitle&" "&TrackTitle&" "&TrackFileName&"</div>"

Response.Write "no artists selected"   
end if

<button type="submit">Submit</button>  <input type="button" value="BACK!"onClick="history.back();">

Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros