<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p13")
'''''''''''''''''''''''''''''''''''''''''''''''
%>
<%
dim voteArr,voteItemArr,catalogid
if(request.queryString("catalogid")<>"") then
	catalogid=Clng(request.queryString("catalogid"))
else
	response.write("error")
	response.end()
end if
	Set rs = Server.CreateObject("Adodb.RecordSet")				 
	rs.Open "Select id,title,catalogid from t_survey_vote where catalogid="&catalogid&" order by id asc",conn,3,1
	if not rs.eof then
		voteArr=rs.GetRows()
	else
		response.Write("没有找到记录")
		response.End()
	end if
	rs.close
	set rs=nothing
''''''''''''''''''''''''''''''''''初使化''''''''''''''''''''''''''''
dim tempJsStr
tempJsStr=""
tempJsStr=tempJsStr&"document.write('<FORM method=""POST"" name=""VoteForm"" target=""_blank"" action=""/survey/surveyok.asp?catalogid="&catalogid&""" style=""margin:0 0 0 0;"">');"&Chr(10)
tempJsStr=tempJsStr&"document.write('<table width=""100%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">');"&Chr(10)
tempJsStr=tempJsStr&"document.write('<tr>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('  <td></td>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('</tr>');"&Chr(10)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'开始按vote循环
for votei=0 to ubound(voteArr,2)
	'初使化vote头	
	tempJsStr=tempJsStr&"document.write('<tr>');"&Chr(10)
    tempJsStr=tempJsStr&"document.write('<td><table width=""94%""  border=""0"" cellpadding=""0"" cellspacing=""0"">');"&Chr(10)
    tempJsStr=tempJsStr&"document.write('  <tr>');"&Chr(10)
    tempJsStr=tempJsStr&"document.write('    <td width=""13%"">"&(votei+1)&"、</td>');"&Chr(10)
    tempJsStr=tempJsStr&" document.write('   <td>"&voteArr(1,votei)&"</td>');"&Chr(10)
    tempJsStr=tempJsStr&"document.write('  </tr>');"&Chr(10)
	Set rs = Server.CreateObject("Adodb.RecordSet")				 
	rs.Open "Select id,itemName from t_survey_item where voteid="&voteArr(0,votei),conn,3,1
	if not rs.eof then
		voteItemArr=rs.GetRows()
		rs.close
		set rs=nothing
		for i=0 to ubound(voteItemArr,2)
			tempJsStr=tempJsStr&"document.write('<tr>');"&Chr(10)
			tempJsStr=tempJsStr&"document.write('<td><input type=""radio"" name=""vote"&voteArr(0,votei)&""" value="""&voteItemArr(0,i)&"""></td>');"&Chr(10)
			tempJsStr=tempJsStr&"document.write('<td>"&voteItemArr(1,i)&"</td>');"&Chr(10)			
			tempJsStr=tempJsStr&"document.write('</tr>');"&Chr(10)

		next
		set voteItemArr=nothing
	else
		rs.close
		set rs=nothing
	end if
	'vote 尾
	tempJsStr=tempJsStr&"document.write(' </table></td></tr>');"&Chr(10)
next

tempJsStr=tempJsStr&"document.write('<TR>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('    <TD colspan=""2""><div align=""center"">');"&Chr(10)	
tempJsStr=tempJsStr&"document.write('        <input type=image src=""/survey/images/voteSubmit.gif"">&nbsp;&nbsp;');"&Chr(10)
tempJsStr=tempJsStr&"document.write('        <a href=\'/survey/surveylist_s.asp?id="&catalogid&"\' target=""_blank""><img src=""/survey/images/voteView.gif"" border=0></a>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('    </div></TD>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('</TR>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('</TABLE>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('</FORM>');"&Chr(10)
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set file_w = fs.CreateTextFile(server.mappath("/survey/js/survey_"&catalogid&".js"),true)	
file_w.WriteLine(tempJsStr)
file_w.close
set file_w=nothing
response.write("成功生成投票JS文件！引用代码：<br />&lt;script type=&quot;text/javascript&quot; src=&quot;/survey/js/survey_"&catalogid&".js&quot;&gt;&lt;/script&gt;")
response.write("<br>使用方法：将上述引用代码复制并加入到您的模板中即可")
set voteArr=nothing
call connclose()
%>