Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

response.write(function()) problem 1

Status
Not open for further replies.

bitrot

Programmer
Jun 3, 2004
13
US
I wrote this function, and it is supposed to return a string that contains a nice looking table so that we can print it. However, response.write just prints out "False". Anyone run into this before ?

Code:
Function categoryTables()
	response.write("categoryTables()")
	'arrays
	DIM mfgArray, skinTypeArray
	'strings
	DIM mfgName
	'ints
	DIM mfgCount, counter, iter, nOfCols
	
	nOfCols = CINT(4) 'Number of Columns In our table
	counter = CINT(0) 'Mod by nOfCols to figure out which col. were on
	
	'grab global arrays so we don't have to tax the DB
	mfgArray = APPLICATION("globalManufacturerArray") 
	skinTypesArray = APPLICATION("globalSkinTypesArray") 

	Response.write("mfg is a :" & TypeName(APPLICATION("globalManufacturerArray")) & "<br>")
	Response.write("skintype is a :" & TypeName(APPLICATION("globalSkinTypesArray")) & "<br>")

	'This section creates our mfg Table
	categoryTables = categoryTables & "<table>" & VbCrLf
	categoryTables = categoryTables & VbTab & "<tr>"  & VbCrLf
	categoryTables = categoryTables & VbTab & VbTab & "<td colspan='4'>Manufacturers:</td>"  & VbCrLf
	categoryTables = categoryTables & VbTab & "<tr>"  & VbCrLf
	
	FOR iter = LBOUND(mfgArray, 2) TO UBOUND(mfgArray, 2) 
		response.write("in counter: (" & counter & ")<br>")
		
		
		mfgName = mfgArray(0, iter) 'make our code readable
		mfgCount = mfgArray(1, iter)
		response.write("mfgName: " & mfgName & "<br>")
		response.write("mfgCount: " & mfgCount & "<br>")
		
		'Populate Our Table
		IF (counter Mod nOfCols) = 0 THEN
			categoryTables = categoryTables & VbTab & "<tr>"  & VbCrLf & VbTab & VbTab & "<td ><a href='DisplayProducts.asp?DispType=MFG&Criteria=" & mfgName & "&session_id=" & session_id & "'>" & mfgName & "</a> (" & mfgCount & ")</td>"  & VbCrLf
		ELSEIF (counter Mod nOfCols) = 3 THEN
			categoryTables = categoryTables &VbTab & VbTab & "<td ><a href='DisplayProducts.asp?DispType=MFG&Criteria=" & mfgName & "&session_id=" & session_id & "'>" & mfgName & "</a> (" & mfgCount & ")</td>"  & VbCrLf & VbTab & "<tr>"  & VbCrLf
		ELSE
			categoryTables = categoryTables & VbTab & VbTab & "<td ><a href='DisplayProducts.asp?DispType=MFG&Criteria=" & mfgName & "&session_id=" & session_id & "'>" & mfgName & "</a> (" & mfgCount & ")</td>"  & VbCrLf
		END IF

		counter = counter + 1 'increment our column counter
	NEXT
	
	'Add the required number of cells to balance our table row, then close the row.
	IF NOT (counter Mod nOfCols) = 0 THEN
		FOR iter = counter Mod nOfCols to 3 
			categoryTables = categoryTables &VbTab & VbTab & "<td></td>" & VbCrLf
		NEXT
		categoryTables = categoryTables &VbTab & "</tr>" & VbCrLf
	ELSE
		categoryTables = categoryTables &VbTab & "</tr>" & VbCrLf
	END IF
	
	categoryTables = categoryTables = "</table>" & VbCrLf	
	

End Function

The output is this :

categoryTables()mfg is a :Variant()
skintype is a :Variant()
in counter: (0)
mfgName: manufactuer1
mfgCount: 1
in counter: (1)
mfgName: manufactuer2
mfgCount: 2
in counter: (2)
mfgName: manufactuer3
mfgCount: 1
False

TIA
 
have you tried :

temp = categoryTables()
response.write(temp)

?
that false looks like it's coming from somewhere else, because there's no other response.writes in your code, and if you're response.writing the function out it would appear last as the false is landing. also in the pattern of output, looks like you're writing out type, ubound and counter, in the pattern you're using you're not getting a last counter, is there perchance that the variable for counter is getting killed somewhere somehow and it's what's actually reporting as false?

[thumbsup2]DreX
aKa - Robert
 
gude iye!

i forgot my tennis racket today, so, i cant read worth a *** :)

[thumbsup2]DreX
aKa - Robert
 
Nice catch man, nice catch... thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top