<%
function FormatFormField(fname,ftype,fstyle,fdefault,fbindtable,fpara)
	dim ret,tarr,i,paraarr
	select case ftype
		case "text"
			ret="<input type=""text"" name="""&fname&""" value="""&fdefault&""" "&fstyle&">"
		case "password"
			ret="<input type=""password"" name="""&fname&""" value="""&fdefault&""" "&fstyle&">"
		case "select"
			ret=ret&"<select name="""&fname&""">"				
				if(fbindtable=0 and fdefault<>"") then					
					tarr=split(fdefault,vbcrlf)
					for i=0 to ubound(tarr)
						if(tarr(i)<>"") then
							ret=ret&"<option value="""&tarr(i)&""">"&tarr(i)&"</option>"
						end if
					next
				elseif(fbindtable=1 and fpara<>"") then
					paraarr=split(fpara,"|")
					if(ubound(paraarr)=2) then
						set rs=server.createobject("adodb.recordset")
						rs.open "select "&paraarr(1)&","&paraarr(2)&" from "&paraarr(0),conn,3,1
						while not rs.eof
							ret=ret&"<option value="""&rs(0)&""">"&rs(1)&"</option>"
							rs.movenext
						wend
						rs.close
						set rs=nothing
					end if
				end if
			ret=ret&"</select>"
		case "radio"		
				if(fbindtable=0 and fdefault<>"") then					
					tarr=split(fdefault,vbcrlf)
					for i=0 to ubound(tarr)
						if(tarr(i)<>"") then
							ret=ret&"<input name="""&fname&""" type=""radio"" value="""&tarr(i)&""" />"&tarr(i)
						end if
					next
				elseif(fbindtable=1 and fpara<>"") then
					paraarr=split(fpara,"|")
					if(ubound(paraarr)=2) then
						set rs=server.createobject("adodb.recordset")
						rs.open "select "&paraarr(1)&","&paraarr(2)&" from "&paraarr(0),conn,3,1
						while not rs.eof
							ret=ret&"<input name="""&fname&""" type=""radio"" value="""&rs(0)&""" />"&rs(1)
							rs.movenext
						wend
						rs.close
						set rs=nothing
					end if
				end if
			case "checkbox"		
				if(fbindtable=0 and fdefault<>"") then					
					tarr=split(fdefault,vbcrlf)
					for i=0 to ubound(tarr)
						if(tarr(i)<>"") then
							ret=ret&"<input name="""&fname&""" type=""checkbox"" value="""&tarr(i)&""" />"&tarr(i)
						end if
					next
				elseif(fbindtable=1 and fpara<>"") then
					paraarr=split(fpara,"|")
					if(ubound(paraarr)=2) then
						set rs=server.createobject("adodb.recordset")
						rs.open "select "&paraarr(1)&","&paraarr(2)&" from "&paraarr(0),conn,3,1
						while not rs.eof
							ret=ret&"<input name="""&fname&""" type=""checkbox"" value="""&rs(0)&""" />"&rs(1)							
							rs.movenext
						wend
						rs.close
						set rs=nothing
					end if
				end if
			case "textarea"
				ret=ret&"<textarea name="""&fname&""" "&fstyle&">"&fdefault&"</textarea>"
			case "editor"
				ret=ret&"<textarea style=""display:none;"" name="""&fname&""">"&fdefault&"</textarea>"
				ret=ret&"<iframe ID=""eWebEditor1"" src=""webedit/editor.asp?fieldname="&fname&""" frameborder=""0"" scrolling=""no"" width=""100%"" height=""350""></iframe>	"
			case "img"
				ret=ret&"<input name="""&fname&""" type=""text"" id="""&fname&""" size=""30"">"
				ret=ret&"<input type=""button"" name=""Button"" value=""上传->"" onClick=""javascript:document.getElementById('"&fname&"').value=window.showModalDialog('upimg.htm','','dialogHeight:130px;dialogWidth:410px;help:no;status:no;scroll:no')"">"
			case "file"
				ret=ret&"<input name="""&fname&""" type=""text"" id="""&fname&""" size=""30"">"
				ret=ret&"<input type=""button"" name=""Button"" value=""上传->"" onClick=""javascript:document.getElementById('"&fname&"').value=window.showModalDialog('upimg.htm','','dialogHeight:130px;dialogWidth:410px;help:no;status:no;scroll:no')"">"
				case "date"
				ret=ret&"<input name="""&fname&""" type=""text"" id="""&fname&""" size=""8"">"
				ret=ret&"<input type=""button"" name="""&fname&"_date"" value=""选择日期"" onClick=""OpenWindowAndSetValue('Inc/SelectDate.asp',230,190,window,document.form1."&fname&");"">"
			case "color"
				ret=ret&"<input name="""&fname&""" type=""text"" id="""&fname&""" size=""8"">"
				ret=ret&"<input type=""button"" name="""&fname&"_color"" value=""选色"" onClick=""OpenWindowAndSetValue('editor/selcolor.htm',230,190,window,document.form1."&fname&");"">"
	end select
	FormatFormField=ret
end function

function FormatFormFieldWithValue(fname,ftype,fstyle,fdefault,fbindtable,fpara,fcurdata)
	dim ret,tarr,i,paraarr,rs,sele
	select case ftype
		case "text"
			ret="<input type=""text"" name="""&fname&""" value="""&fcurdata&""" "&fstyle&">"
		case "password"
			ret="<input type=""password"" name="""&fname&""" value="""&fcurdata&""" "&fstyle&">"
		case "select"
			ret=ret&"<select name="""&fname&""">"				
				if(fbindtable=0 and fdefault<>"") then					
					tarr=split(fdefault,vbcrlf)
					for i=0 to ubound(tarr)
						if(tarr(i)<>"") then
							if(cstr(fcurdata)=cstr(tarr(i))) then
								sele=" selected=""selected"""
							else
								sele=""
							end if
							ret=ret&"<option value="""&tarr(i)&""""&sele&">"&tarr(i)&"</option>"
						end if
					next
				elseif(fbindtable=1 and fpara<>"") then
					paraarr=split(fpara,"|")
					if(ubound(paraarr)=2) then
						set rs=server.createobject("adodb.recordset")
						rs.open "select "&paraarr(1)&","&paraarr(2)&" from "&paraarr(0),conn,3,1
						while not rs.eof
							if(cstr(fcurdata)=cstr(rs(0))) then
								sele=" selected=""selected"""
							else
								sele=""
							end if
							ret=ret&"<option value="""&rs(0)&""""&sele&">"&rs(1)&"</option>"
							rs.movenext
						wend
						rs.close
						set rs=nothing
					end if
				end if
			ret=ret&"</select>"
		case "radio"		
				if(fbindtable=0 and fdefault<>"") then					
					tarr=split(fdefault,vbcrlf)
					for i=0 to ubound(tarr)
						if(tarr(i)<>"") then
							if(cstr(fcurdata)=cstr(tarr(i))) then
								sele=" checked=""checked"""
							else
								sele=""
							end if
							ret=ret&"<input name="""&fname&""" type=""radio"" value="""&tarr(i)&""""&sele&" />"&tarr(i)
						end if
					next
				elseif(fbindtable=1 and fpara<>"") then
					paraarr=split(fpara,"|")
					if(ubound(paraarr)=2) then
						set rs=server.createobject("adodb.recordset")
						rs.open "select "&paraarr(1)&","&paraarr(2)&" from "&paraarr(0),conn,3,1
						while not rs.eof
							if(cstr(fcurdata)=cstr(rs(0))) then
								sele=" checked=""checked"""
							else
								sele=""
							end if
							ret=ret&"<input name="""&fname&""" type=""radio"" value="""&rs(0)&""""&sele&" />"&rs(1)
							rs.movenext
						wend
						rs.close
						set rs=nothing
					end if
				end if
			case "checkbox"		
				if(fbindtable=0 and fdefault<>"") then					
					tarr=split(fdefault,vbcrlf)
					for i=0 to ubound(tarr)
						if(tarr(i)<>"") then
							if(cstr(fcurdata)=cstr(tarr(i))) then
								sele=" checked=""checked"""
							else
								sele=""
							end if
							ret=ret&"<input name="""&fname&""" type=""checkbox"" value="""&tarr(i)&""""&sele&" />"&tarr(i)
						end if
					next
				elseif(fbindtable=1 and fpara<>"") then
					
					paraarr=split(fpara,"|")
					if(ubound(paraarr)=2) then
						set rs=server.createobject("adodb.recordset")
						rs.open "select "&paraarr(1)&","&paraarr(2)&" from "&paraarr(0),conn,3,1
						while not rs.eof
							if(cstr(fcurdata)=cstr(rs(0))) then
								sele=" checked=""checked"""
							else
								sele=""
							end if
							ret=ret&"<input name="""&fname&""" type=""checkbox"" value="""&rs(0)&""""&sele&" />"&rs(1)							
							rs.movenext
						wend
						rs.close
						set rs=nothing
					end if
				end if
			case "textarea"
				ret=ret&"<textarea name="""&fname&""" "&fstyle&">"&fcurdata&"</textarea>"
			case "editor"
				ret=ret&"<textarea style=""display:none;"" name="""&fname&""">"&fcurdata&"</textarea>"
				ret=ret&"<iframe ID=""eWebEditor1"" src=""webedit/editor.asp?fieldname="&fname&""" frameborder=""0"" scrolling=""no"" width=""100%"" height=""350""></iframe>	"
			case "img"
				ret=ret&"<input name="""&fname&""" type=""text"" id="""&fname&""" value="""&fcurdata&""" size=""30"">"
				ret=ret&"<input type=""button"" name=""Button"" value=""上传->"" onClick=""javascript:document.getElementById('"&fname&"').value=window.showModalDialog('upimg.htm','','dialogHeight:130px;dialogWidth:410px;help:no;status:no;scroll:no')"">"
			case "file"
				ret=ret&"<input name="""&fname&""" type=""text"" id="""&fname&""" value="""&fcurdata&""" size=""30"">"
				ret=ret&"<input type=""button"" name=""Button"" value=""上传->"" onClick=""javascript:document.getElementById('"&fname&"').value=window.showModalDialog('upimg.htm','','dialogHeight:130px;dialogWidth:410px;help:no;status:no;scroll:no')"">"
				case "date"
				ret=ret&"<input name="""&fname&""" type=""text"" id="""&fname&""" value="""&fcurdata&""" size=""8"">"
				ret=ret&"<input type=""button"" name="""&fname&"_date"" value=""选择日期"" onClick=""OpenWindowAndSetValue('Inc/SelectDate.asp',230,190,window,document.form1."&fname&");"">"
			case "color"
				ret=ret&"<input name="""&fname&""" type=""text"" id="""&fname&""" value="""&fcurdata&""" size=""8"">"
				ret=ret&"<input type=""button"" name="""&fname&"_color"" value=""选色"" onClick=""OpenWindowAndSetValue('editor/selcolor.htm',230,190,window,document.form1."&fname&");"">"
	end select
	FormatFormFieldWithValue=ret
end function
%>