在線請教!!!

顺子 2004-08-06 08:58:49
怎樣能用js寫能在一個<form>里面有4個submit銨鈕,并且處理的問題不同,如以下程序:
<!--#include file="GetConnStr.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>樣品需求申請單</title>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<script language="javascript">
function checkfield(btn){
var form = document.form1;
btn.disabled = true;
form.submit();
}
</script>
<body>
<%
connstr = Get6204ConnStr()
Set conn = Server.CreateObject("ADODB.connection")
Set rs = Server.CreateObject("ADODB.Recordset")
conn.open connstr
'將num ,datereply字段insert表testspl1中,如果表有num這個值,則update表中的datereply的值
if Request("stype") = "squery" then
num=request("number")
date1=request("datereply")
sqla="select NUM from testspl1 where NUM='"&num&"'"
rs.open sqla,conn,3,3
if not rs.eof then
sqlb="update testspl1 set datereply='"&date1&"' where NUM='"&num&"'"
conn.execute sqlb
else
sql="insert into testspl1(NUM,DATEREPLY) VALUES('"&num&"','"&date1&"')"
conn.execute sql

end if
end if
%>
<% '要新增到testspl2數据insert into testspl2 表中
If request.Form("ctype")="add" Then
num=trim(request.Form("number"))
ser_no=trim(request.Form("ser_no"))
hisdate=trim(request.Form("hisdate"))
cond=trim(request.Form("cond"))
source1=trim(request.Form("source"))
condsta=trim(request.Form("condsta"))
solution=trim(request.Form("solution"))
sqlx="insert into TESTSPL2(NUM,SER_NO,HISDATE,COND,SOURCE,CONDSTA,SOLUTION) VALUES('"&num&"','"&ser_no&"','"&hisdate&"','"&cond&"','"&source1&"','"&condsta&"','"&solution&"')"
conn.execute(sqlx)
response.write("<script langeuage=javascript>{window.alert('添加成功');window.location.href='120.asp'}</script>")
response.end
end if%>
<form name="form1" method="post" action="120.asp">
<table width="100%" border="1" cellspacing="0">
<tr>
<td width="6%">樣品單號</td>
<td width="18%"><input name="number" type="text" size="10" value="<%=request("number")%>"><!--<input name="search" type="submit" value="查詢">--></td>
<td width="25%"> </td>
<td width="17%"> </td>
<td width="18%"> </td>
<td width="16%"> </td>
</tr>
<tr>
<td>回覆時間</td>
<td >
<Div align="left" id="text_div"></DIV>
<div align="right">
<input name="按鈕" type="button" onclick="document.all.text_div.innerHTML='<input type=text name=datereply size=10 >'" value="新增">
</div>
<td valign="bottom"><div align="left"><input type="button" name="upinsert" value="按鈕" onClick="checkfield(this);">
<input name="stype" type="hidden" value="squery" size="8"> <!--<a href="aaa.asp?action=change">送出</a>--></div>
</td></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="6">樣品制樣過程紀錄
<input name="addtable" type="button" value="查詢數據" onClick="checkfield(this);">
<input name="ttype" type="hidden" value="add1">
<input name="Button" type="button" id="button" onClick="checkfield(this);" value="增加表格" >
<input name="action" type="hidden" value="addtable" >
</tr>
</table>
<table width="100%" border="1" cellspacing="0">
<tr>
<td>項次</td>
<td>紀錄日期</td>
<td>狀況</td>
<td>訊息來源</td>
<td>狀況別</td>
<td>處理對策</td>
</tr>
</table>
<% '以下是要增加數據到testspl2中,同時顯示上述樣品單號的資料
if request.Form("ttype")="add1" then
if num=request.Form("number")="" then
response.Write("num字段不能為空")
else
sql2="select max(convert(int,ser_no)) as sno from testspl2 where num='"&num&"'"
set rsb=conn.execute(sql2)
tab1=rsb("sno")
ssql="select num,ser_no,hisdate,cond,source,condsta,solution from testspl2 where num='"&num&"'"
set rsa=conn.execute(ssql)
end if
'顯示字段num的值与request.form("number")相符的數據
do while not rsa.eof %>
<table width="100%" border="1" align="center" cellspacing="0">
<tr>
<td width="17%"><div align="center"><%= rsa("SER_NO") %></div></td>
<td width="17%"><div align="center"><%= rsa("HISDATE") %></div></td>
<td width="14%"><div align="center"><%= rsa("COND") %></div></td>
<td width="18%"><div align="center"><%= rsa("SOURCE") %></div></td>
<td width="17%"><div align="center"><%= rsa("CONDSTA") %></div></td>
<td width="17%" colspan="2"><div align="center"><%= rsa("SOLUTION") %></div></td>
</tr>
</table>
<% rsa.movenext
loop
end if
'增加表格
%>

<table width="100%" border="1" align="center" cellspacing="0">

<%
If request.form("action")="addtable" Then
%>
<tr>
<td width="7%"><div align="center">
<input name="ser_no" type="text" value=" <%= right("00"&(tab1+1),2) %>" size="4">
</div></td>
<td width="14%"><input name="hisdate" type="text" id="hisdate" size="10"></td>
<td width="14%"><input name="cond" type="text" id="cond" size="10"></td>
<td width="20%"><input name="source" type="text" id="source" size="10"></td>
<td width="16%"><input name="condsta" type="text" id="condsta" size="10"></td>
<td width="15%"><input name="solution" type="text" id="solution" size="10"></td>
<td width="14%"><!--<input type="submit" name="save" value="送出"> -->
<input type="button" name="insert" value="存檔" onClick="checkfield(this);">
<input name="ctype" type="hidden" value="add">
<!--<div align="center"> <a href="abc1.asp">存檔</a></div>--></td>
</tr>
<% End If %>
</table>
</form>
<% 'End If %>
<table width="100%" border="1" cellspacing="0">
<tr>
<td colspan="6">樣品室備泩:</td>
</tr>
</table>
</body>
</html>
...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
janlon 2004-08-13
  • 打赏
  • 举报
回复
调用四个函数处理,或者用onClick="javascript:window.open('default.asp','_self')"类似的事件进行处理!!!
978107 2004-08-13
  • 打赏
  • 举报
回复
you can write it like this:

you must understand the submit button not only write the submit, you can write a commonly button, but you must write the commonly button Onclick event.
example:
<input type="button" name="b1" onclick="submitCheck('b1')">
<input type="button" name="b2" onclick="submitCheck('b2')">
<input type="button" name="b3" onclick="submitCheck('b3')">
<input type="button" name="b4" onclick="submitCheck('b4')">

in the javscript:
<script language="javascript">
function submitCheck(obj)
{
if (obj == "b1")
....
else if (obj == "b2")
......
........
}
</script>

you will solute the problem!
顺子 2004-08-13
  • 打赏
  • 举报
回复
如果改成4個button做,那有應該怎麼樣處理呀,
duoduobaba 2004-08-06
  • 打赏
  • 举报
回复
四个按钮onClick的时间调用不同的函数就可以啊
顺子 2004-08-06
  • 打赏
  • 举报
回复
只要有人給我正確答案之后,再給分

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧