经典 Asp 中的发票 +阿贾克斯

发布于 2024-10-22 03:30:06 字数 1591 浏览 2 评论 0原文

我需要一个发票表格,

请帮助我了解如何将所有数据一次插入发票表中。

我正在使用文本框来获取项目的所有详细信息。

这是从表中获取项目详细信息的代码。

enter code here<% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))%>
          <tr>
            <td><input name="dipatchid" type="text" id="dipatchid" value="<%=(Recordset1.Fields.Item("dispatchid").Value)%>" size="5" /></td>
            <td><input name="dispatchdate" type="text" id="dispatchdate" value="<%=(Recordset1.Fields.Item("dis_date").Value)%>" /></td>
            <td><input type="hidden" name="custid_" id="custid_" />
              <input name="From_" type="text" id="From_" value="<%=(Recordset1.Fields.Item("from_").Value)%>" /></td>
            <td><input name="to_" type="text" id="to_" value="<%=(Recordset1.Fields.Item("To_").Value)%>" /></td>
            <td><input name="hrs" type="text" id="hrs" value="<%=(Recordset1.Fields.Item("total_hrs").Value)%>" size="5" /></td>
            <td><input name="rate_" type="text" id="rate_" size="8" /></td>
            <td><input name="totalamt" type="text" id="totalamt" size="10" /></td>
            <td><img src="imgs/error_icon.png" width="16" height="16" alt="Remove" /></td>              </tr>
          <% Repeat1__index=Repeat1__index+1  Repeat1__numRows=Repeat1__numRows-1  Recordset1.MoveNext() Wend %>

在此处输入图像描述

I need to a form for invoicing,

Please help me to have some Idea how to insert all the data at once into invoice table.

I am using text box to get all details for items .

here is the code for get details of items from table.

enter code here<% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))%>
          <tr>
            <td><input name="dipatchid" type="text" id="dipatchid" value="<%=(Recordset1.Fields.Item("dispatchid").Value)%>" size="5" /></td>
            <td><input name="dispatchdate" type="text" id="dispatchdate" value="<%=(Recordset1.Fields.Item("dis_date").Value)%>" /></td>
            <td><input type="hidden" name="custid_" id="custid_" />
              <input name="From_" type="text" id="From_" value="<%=(Recordset1.Fields.Item("from_").Value)%>" /></td>
            <td><input name="to_" type="text" id="to_" value="<%=(Recordset1.Fields.Item("To_").Value)%>" /></td>
            <td><input name="hrs" type="text" id="hrs" value="<%=(Recordset1.Fields.Item("total_hrs").Value)%>" size="5" /></td>
            <td><input name="rate_" type="text" id="rate_" size="8" /></td>
            <td><input name="totalamt" type="text" id="totalamt" size="10" /></td>
            <td><img src="imgs/error_icon.png" width="16" height="16" alt="Remove" /></td>              </tr>
          <% Repeat1__index=Repeat1__index+1  Repeat1__numRows=Repeat1__numRows-1  Recordset1.MoveNext() Wend %>

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安稳善良 2024-10-29 03:30:06

为了实现这一点,您需要跟踪两件事:

  • 将要插入的行数
  • 每行的数据

做到这一点的技巧很简单。显示数据时,您可以使用循环数来递增变量。

<%
iNumberOfRecords = 0
Do Until Recordset1.EOF
  %>
  <tr>
    <td>
      <input name="dipatchid" type="text" id="..." value="<%=Recordset1("dispatchid")%>" />
    </td>
    ...
  </tr>
  <%
  iNumberOfRecords = iNumberOfRecords + 1
Recordset1.MoveNext
loop
Recordset1.Close
%>

在关闭

标记之前,请将其放入隐藏字段中。

<input type="hidden" name="iNumberOfRecords" value="<%=iNumberOfRecords%>" />

接下来,在您提交的页面上,循环 iNumberOfRecords 次以插入所有行。

<%
for i = 1 to CInt(Request.Form("iNumberOfRecords"))
  idOfRecord = GetFormValue("dipatchid", i)
  otherField = GetFormValue("otherField", i)

  SQL = "INSERT INTO tblInvoices(dispatchid, otherfield) VALUES ( " & idOfRecord & ", " & otherfield & " )"
  Connectionobject.Execute(SQL)
next

Function GetFormValue(sFormname, iIndex)
  If Request.Form(sFormname).Count >= iIndex And iIndex > 0 Then
    GetFormValue = Request.Form(sFormname)(iIndex)
  Else
    GetFormValue = ""
  End If
End Function
%>

(i) 为您获取正确的 Request.Form("...") 项目。

To accomplish this, you will need to keep track of two things:

  • the number of rows that are going to be inserted
  • the data of each row

Tricks to do this, is simple. While you display your data, you increment a variable with the number of loops.

<%
iNumberOfRecords = 0
Do Until Recordset1.EOF
  %>
  <tr>
    <td>
      <input name="dipatchid" type="text" id="..." value="<%=Recordset1("dispatchid")%>" />
    </td>
    ...
  </tr>
  <%
  iNumberOfRecords = iNumberOfRecords + 1
Recordset1.MoveNext
loop
Recordset1.Close
%>

Before you close your <form> tag, you put that in a hidden field.

<input type="hidden" name="iNumberOfRecords" value="<%=iNumberOfRecords%>" />

Next, on the page where you submit to, you loop iNumberOfRecords times to insert all the rows.

<%
for i = 1 to CInt(Request.Form("iNumberOfRecords"))
  idOfRecord = GetFormValue("dipatchid", i)
  otherField = GetFormValue("otherField", i)

  SQL = "INSERT INTO tblInvoices(dispatchid, otherfield) VALUES ( " & idOfRecord & ", " & otherfield & " )"
  Connectionobject.Execute(SQL)
next

Function GetFormValue(sFormname, iIndex)
  If Request.Form(sFormname).Count >= iIndex And iIndex > 0 Then
    GetFormValue = Request.Form(sFormname)(iIndex)
  Else
    GetFormValue = ""
  End If
End Function
%>

The (i) fetches the right Request.Form("...") item for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文