editbook.asp

来自「创建和运行动态、交互的Web服务器应用程序」· ASP 代码 · 共 399 行 · 第 1/2 页

ASP
399
字号
<!--#include file="conn.asp"-->

<%dim bookid
      bookid=request.QueryString("id")%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../images/css2.css" rel="stylesheet" type="text/css">

<script>
	function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}

function showpub()
     {
      document.all.add_publish.style.display=""
     }
</script>

<SCRIPT LANGUAGE="JavaScript">
<!--
function check()
{
    if(document.myform.anclassid.value==0) {
	document.myform.anclassid.focus();
    alert("请选择图书分类!");
	return false;
  }  
    if(checkspace(document.myform.bookname.value)) {
	document.myform.bookname.focus();
    alert("请输入图书名称!");
	return false;
  }  
    if(checkspace(document.myform.isbn.value)) {
	document.myform.isbn.focus();
    alert("请输入书号!");
	return false;
  }
    if(checkspace(document.myform.bookchuban.value)) {
	document.myform.bookchuban.focus();
    alert("请输入出版社!");
	return false;
  }
    if(checkspace(document.myform.shichangjia.value)) {
	document.myform.shichangjia.focus();
    alert("请输入图书单价!");
	return false;
  }
    if(checkspace(document.myform.huiyuanjia.value)) {
	document.myform.huiyuanjia.focus();
    alert("请输入图书会员价!");
	return false;
  }
    if(checkspace(document.myform.banci.value)) {
	document.myform.banci.focus();
    alert("请输入版次!");
	return false;
  }
    if(checkspace(document.myform.yeshu.value)) {
	document.myform.yeshu.focus();
    alert("请输入页数!");
	return false;
  }

}

function checkspace(checkstr) 
{
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

function checkImage(sId)
{
  if(( document.all[sId].value.indexOf(".gif") == -1) && (document.all[sId].value.indexOf(".jpg") == -1)) {
    alert("请选择gif或jpg的图象文件");
    event.returnValue = false;
    }
}

function showedit()
  {
 if(document.all.bkpicedit.checked==true)
      {
      document.all.edit_bookpicup.style.display="";
      document.all.edit_bookpicok.style.display="none";
		}
 else{
      document.all.edit_bookpicup.style.display="none";
      document.all.edit_bookpicok.style.display="";
		}
  }

<%dim count
set rs=server.createobject("adodb.recordset")
    rs.open "select * from shop_Nclass order by Nclassidorder ",conn,1,1%>
var onecount;
onecount=0;
subcat = new Array();
<%
   count = 0
   do while not rs.eof 
%>
subcat[<%=count%>] = new Array("<%= trim(rs("Nclass"))%>","<%= rs("anclassid")%>","<%= rs("Nclassid")%>");
<%
        count = count + 1
        rs.movenext
        loop
        rs.close
%>
		
onecount=<%=count%>;

function changelocation(locationid)
    {
    document.myform.Nclassid.length = 0; 

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { //这句不是很理解
             document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
    }

function changepub(pubid)
    {
    var pubid=pubid;
    document.myform.bookchuban.value=pubid;
    document.all.add_publish.style.display="none";
    } 
 
//-->   
</script>
</head>
<body>

<%dim rs1
  set rs1=server.CreateObject("adodb.recordset")
      rs1.open "select * from shop_books where bookid="&bookid,conn,1,1%>

<table width="90%"  border="0" height=450 cellpadding="0" cellspacing="0">
  <tr><td bgcolor="#ece9d8"><br>
      <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr><td>
            <table width=231  border="0"  cellpadding="0" cellspacing="0">
               <tr valign=bottom>
                 <td background=images/get_img.gif  width=77 height=26><P style='PADDING-LEFT: 7px'><div align="center"><font color=#ffffff>详细资料</font></div></td>
                 <td background=images/lose_img.gif width=77 height=26><P style='PADDING-LEFT: 7px'><div align="center"><a href=managebook.asp><font color=#000000>图书管理</font></a></div></td>
                 <td background=images/lose_img.gif width=77 height=26><P style='PADDING-LEFT: 7px'><div align="center"><a href=addbook.asp><font color=#000000>增加图书</font></a></div></td>
               </tr>
          </table>
        </tr>
      </table>

  <%dim rs22,rs33
    set rs=server.CreateObject("adodb.recordset")
        rs.open "select * from shop_anclass order by anclassidorder",conn,1,1

    set rs22=server.CreateObject("adodb.recordset")
        rs22.open "select nclassid,nclass from shop_Nclass where anclassid="&int(rs1("anclassid")),conn,1,1

    set rs33=server.CreateObject("adodb.recordset")
        rs33.open "select * from shop_publish order by pubjian",conn,1,1%>


      <table width="98%" border="1"  align=center cellspacing="0" cellpadding="0" bordercolordark="#eeeeee" bordercolorlight="#666666">
         <form name="myform" method="post" action="saveaddbook.asp?action=edit&id=<%=bookid%>">
            <tr><td>
                  <table width="100%" border="1"  align=center cellspacing="0" cellpadding="0">
                     <tr><td>
                       <table width="100%" border="0"  align=center cellspacing="1" cellpadding="3" bgcolor="#ffffff">
                          <tr>
                          <td bgcolor="#ece9d8" width="10%" align=right>选择分类&nbsp;</td>
                          <td bgcolor="#ece9d8" colspan="2"><select name="anclassid" size="1" id="anclassid" onChange="changelocation(document.myform.anclassid.options[document.myform.anclassid.selectedIndex].value)">
                          
                          <%do while not rs.eof%>
                          <option value=<%=rs("anclassid")%>
                          <%if int(rs1("anclassid"))=int(rs("anclassid")) then
                               response.Write " selected>"
                            else
                               response.Write ">"
                            end if
                            response.Write trim(rs("anclass"))&"</option>"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?