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
Ajax
Json

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
http://www.tomsmp3.com/AlbumSearch.asp

You will see a very long list 8232 records
If you select any and click on submit it takes you to http://www.tomsmp3.com/SelectAlbums.asp


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

The new code
http://www.tomsmp3.com/musicatable.asp

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

MusicAtable.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html>
<html>
<head>
<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>

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


You can see the above uses this

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.Buffer = false%>
<!-- #include file="db_connection.inc" --> 
{"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
	myArray=oRs1.getrows()
end if

oRs1.Close
Set oRs1 = Nothing
oConn.Close
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
next
%>
]}

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="db_connection.inc" -->
<%
dim searchWord, searchIN
dim strFont1
dim strFont2
searchIN = ""

goodData=0

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 ) & "'," 
next
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
	goodData=1
	arrResults=oRs1.getrows()
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>"
    next
else


Response.Write "no artists selected"   
end if


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

thanks
ASKER CERTIFIED SOLUTION
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