<!--#include file="conn.asp"-->
<!--#include file="inc/function.asp"-->
<%
dim action,id
action=Trim(Request.QueryString("action"))
id=Trim(Request.QueryString("id"))

opendb

Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	set AskD.myConn =conn
	AskD.myPredb =predb
	AskD.Getsetting()
	AskD.GetUserRole()
	siteinfo=AskD.siteinfo
	setting=AskD.setting
	UserRole=AskD.UserRole

if action="1" then
   call saveadd()
else
   call main()
end if

	set AskD.myConn =Nothing
    Set AskD = Nothing
closedb

sub saveadd()
   dim uid,ans,fck
   uid=Trim(Request.QueryString("uid"))
   if uid<>Request.Cookies("Muser")  then
      Response.Write("您无权修改！")
      Response.End()
   end if
   fck=Trim(Request.Form("fck"))
   ans=Trim(Request.Form("ans"))
   ans=AskD.chkAllow(ans,3)
   IF fck<>"1" Then ans=AskD.HTMLcode(ans)
   conn.execute("update "&predb&"ans set anscontent='"&ans&"',moditime='"&now()&"' where ansid="&id)
   Response.Write("修改成功！")
%>
<input type="button" name="button2" id="button2" value="  确 定  " onClick="new parent.dialog().reset();"/>
<%
end sub


sub main()
dim rs,anscontent,AnsUser,fck
   set rs=conn.execute("select anscontent,AnsUser from "&predb&"ans where ansid="&id)
   anscontent=rs(0)
   AnsUser=rs(1)
set rs=nothing
IF instr(anscontent,"<")>0 Then fck=1
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>回答补充</title>
<link href="Template/<%= siteInfo(11) %>/css/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="JS/MyErr.js"></script>
<script language="javascript">
 function ChkAsk()
{
var rID='<%= Request.Cookies("Muser") %>';
  if (rID=="")
   {
    //openWindow('user/login.asp', '470', '350', '登录');
	var a = new xWin("1",240,200,"<%= siteInfo(4) %>","请先登录再行发布提问！");
	return false;
   }
}

function ChkPut(put,text,num)
{
	if(put.value.length >num)
	{
		put.value = put.value.substring(0,num);
	}
	else
	{
		text.innerText = num - put.value.length;
	}
}
</script>
</head>
<body>
<div class="shortbox">
<form action="?id=<%= id %>&uid=<%= AnsUser %>&action=1" method="post" onSubmit="return ChkAsk();"><input name="fck" type="hidden" value="<%= fck %>">
		<fieldset class="a_p">
			<legend class="a_l">我的回答</legend>
	        <div class="a_c"><textarea name="ans" rows="8" style="width:390px;overflow: hidden;" onKeyDown="ChkPut(this,nr,10000)" onKeyUp="ChkPut(this,nr,10000)"><%= anscontent %></textarea></div>
		    <div class="a_i">可输入 <b><span id="nr">10000</span></b> 字</div>
            <div class="a_rp">上传相关文件：<input name="app" type="file" size="33" style="height:20px"/></div>
            <div class="a_rp">参考文献资料：<input name="app" type="text" size="43" /></div>
        </fieldset>
            <div class="a_s">
              <input type="submit" name="button" id="button" value=" 提交修改 " /> 
               <input type="button" name="button2" id="button2" value="  取 消  " onClick="new parent.dialog().reset();"/>
            </div>
</form>
</div>
</body>
</html>
<% end sub %>