获取使用Javascript添加的表单字段

时间:2014-11-27 08:11:45

标签: javascript html forms

当用户点击“添加新项目”时,我使用下面的代码添加新的产品系列,但是一旦我提交表单,就无法找到添加的行。

我试过转储表单,出现的唯一表单字段是加载后页面上的那些字段,因此我无法获取其余行的数据。

我试过没有运气的情况下移动表格标签

下面是包含我用来添加新行的脚本的页面:

<cfinclude template="header.cfm">
<cfparam name="form.step" default="1">
<cfparam name="form.submit" default="">

<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
var currentItem = 1;
$('#addnew').click(function(){
currentItem++;
$('#items').val(currentItem);
var strToAdd = '<tr><td class="Copy" valign="top">Item Name:</td><td><input type="text" name="Itemname'+currentItem+'" id="Itemname'+currentItem+'" required="yes" message="Please enter a Name" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Item Description:</td><td><input type="text" name="ItemDesc'+currentItem+'" id="ItemDesc'+currentItem+'" required="yes" message="Please enter a Description" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Quantity</td><td><input type="text" name="Quantity'+currentItem+'" id="Quantity'+currentItem+'" required="yes" message="Please enter a Quantity" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Product Code:</td><td><input type="text" name="Code'+currentItem+'" id="Code'+currentItem+'" required="yes" message="Please enter a Code" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Price:</td><td><input type="text" name="Price'+currentItem+'" id="Price'+currentItem+'" required="yes" message="Please enter a Price" class="TextBlock"></td></tr>';
  $('#data').append(strToAdd);

 });
 });

 //]]>
 </script>


<table border="0" cellpadding="0" cellspacing="1" width="100%" class="Border" align="center">
<tr>
    <td class="CopyWhite" align="left" background="images/tab_bg.gif" colspan="2">Add a new invoice</td>
</tr>

<cfoutput>
    <cfif form.step eq 1>
        <form method="post" action="inv_new.cfm" enctype="multipart/form-data">
            <cfquery name="get_vendors" datasource="#application.db#">
                SELECT * FROM tblpassVendor
                WHERE vendoractive = 1
                AND companyid = #session.companyid#
            </cfquery>
            <tr>
                <td class="Copy" valign="top">Invoice Using:</td>
                <td>
                    <Select name="INVBY">
                        <cfloop query="get_vendors">
                            <option value="#vendorid#">#vendorname#</option>
                        </cfloop>
                    </Select>
                </td>
            </tr>
            <tr>
                <td class="Copy" align="center" colspan="2">
                <input type="Submit" name="Submit" value="Submit" class="submitbutton">
                <input type="hidden" name="step" value="2" />
                <input type="Reset" name="Reset" value="Reset" class="submitbutton">
                </td>
            </tr>
        </form>
    </cfif>
    <cfif form.step eq 2>
        <form method="post" action="inv_new.cfm" enctype="multipart/form-data">
            <input type="hidden" name="vendor" value="#FORM.INVBY#" />
            <tr>
                <td class="Copy" valign="top">Order Details:</td>
                <td>
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Reference Number:</td>
                <td>
                    <input type="text" name="REFNUM" required="yes" message="Please enter a User Name" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Billing Details:</td>
                <td>
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Name:</td>
                <td>
                    <input type="text" name="NAME" required="yes" message="Please enter a Name" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Surname:</td>
                <td>
                    <input type="text" name="LNAME" required="yes" message="Please enter a Surname" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Tel:</td>
                <td>
                    <input type="text" name="TEL" required="yes" message="Please enter a Tel" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Email:</td>
                <td>
                    <input type="text" name="EMAIL" required="yes" message="Please enter a Email" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Address line 1:</td>
                <td>
                    <input type="text" name="ADDR1" required="yes" message="Please enter Address line 1" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Address line 2:</td>
                <td>
                    <input type="text" name="ADDR2" required="yes" message="Please enter Address line 2" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">City/Town:</td>
                <td>
                    <input type="text" name="CITY" required="yes" message="Please enter a City/Town" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Province/Region:</td>
                <td>
                    <input type="text" name="REGION" required="yes" message="Please enter a Province/Region" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Country:</td>
                <td>
                    <input type="text" name="COUNTRY" required="yes" message="Please enter a Country" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">ZIP/Postal Code:</td>
                <td>
                    <input type="text" name="ZIP" required="yes" message="Please enter a ZIP/Postal Code" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" align="center" colspan="2">
                <input type="Submit" name="Submit" value="Submit" class="submitbutton">
                <input type="hidden" name="step" value="3" />
                <input type="Reset" name="Reset" value="Reset" class="submitbutton">
                </td>
            </tr>
        </form>
    </cfif>
    <cfif form.step eq 3>
        <!---WRITE DATA TO TBLINV--->
        <cfquery name="write_inv" datasource="#application.db#" result="test">
            INSERT INTO tblpassInv
            (INVVENDORID,INVREF,INVNAME,INVLNAME,INVTEL,INVEMAIL,INVADDR1,INVADDR2,INVCITY,INVREGION,INVCOUNTRY,INVZIP,INVCOMPANY,INVCREATEDBY,INVDATECREATED,INVACTIVE,INVSEND)
            VALUES
            (#form.vendor#,'#form.REFNUM#','#form.NAME#','#form.LNAME#','#form.TEL#','#form.EMAIL#','#form.ADDR1#','#form.ADDR2#','#form.CITY#','#form.REGION#','#form.COUNTRY#','#form.ZIP#',#session.companyid#,#session.adminid#,#createodbcdatetime(now())#,1,0)
        </cfquery>
        <cfset NewPrimaryKey = test.GENERATED_KEY>
        <!---<cfinclude template="inv_amend_prods_new.cfm">--->
        <form method="post" action="inv_new.cfm" enctype="multipart/form-data">
            <tr>
                <td class="Copy" valign="top">Products/Line Items:</td>
                <td>
                </td>
            </tr>
            <tr>
            <td colspan="2">
            <table border="0" id="data" cellpadding="0" cellspacing="1" width="100%" class="Border" align="center">
            <tr>
                <td class="Copy" valign="top">Item Name:</td>
                <td>
                    <input type="text" name="Itemname1" id="Itemname1" required="yes" message="Please enter a Name" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Item Description:</td>
                <td>
                    <input type="text" name="ItemDesc1" id="ItemDesc1" required="yes" message="Please enter a Description" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Quantity</td>
                <td>
                    <input type="text" name="Quantity1" id="Quantity1" required="yes" message="Please enter a Quantity" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Product Code:</td>
                <td><input type="text" name="Code1" id="Code1" required="yes" message="Please enter a Code" class="TextBlock"></td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Price:</td>
                <td><input type="text" name="Price1" id="Price1" required="yes" message="Please enter a Price" class="TextBlock"></td>
            </tr>
            </table>
            </td>
            </tr>
            <tr>
                <td>
                <input type="Submit" name="Submit" value="Submit" class="submitbutton">
                <input type="button" id="addnew" name="addnew" value="Add new item" />
                <input type="hidden" id="items" name="items" value="1" />
                <input type="hidden" name="step" value="4" />
                <input type="hidden" name="invid" value="#NewPrimaryKey#" />
                </td>
            </tr>
        </form>
    </cfif>
    <cfif form.step eq 4>
        <cfdump var="#form#">
        <form method="post" action="inv_new.cfm" enctype="multipart/form-data">
            <tr>
                <td class="Copy" valign="top">Display all details for invoice:</td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                <input type="Submit" name="Submit" value="Submit" class="submitbutton">
                <input type="button" id="addnew" name="addnew" value="Add new item" />
                <input type="hidden" id="items" name="items" value="1" />
                <input type="hidden" name="step" value="5" />
                <input type="hidden" name="invid" value="#form.invid#" />
                </td>
            </tr>
        </form>
    </cfif>
    <cfif form.step eq 5>
        <form method="post" action="inv_new.cfm" enctype="multipart/form-data">
            <tr>
                <td class="Copy" valign="top">Bcc:</td>
                <td>
                    <input type="text" name="bcc" required="yes" message="Please enter a bcc" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td>
                <input type="Submit" name="Submit" value="Submit" class="submitbutton">
                <input type="button" id="addnew" name="addnew" value="Add new item" />
                <input type="hidden" id="items" name="items" value="1" />
                <input type="hidden" name="step" value="6" />
                <input type="hidden" name="invid" value="#form.invid#" />
                </td>
            </tr>
        </form>
    </cfif>
    <cfif form.step eq 6>
        <cfset invid = form.invid>
        <cfinclude template="inv_mail.cfm">
    </cfif>
</cfoutput>
<cfinclude template="footer.cfm">

页面源代码(页眉和页脚):

<!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" />
<link rel="shortcut icon" href="favicon.ico" >
<link rel="stylesheet" href="style/loginstyle.css" type="text/css">
<link rel="stylesheet" type="text/css" href="mailstyle.css">
<link type="text/css" rel="stylesheet" href="style/jquery.miniColors.css" />
<style type="text/css">
@import "calendar/jquery.datepick.css";
/* Or use these for a ThemeRoller theme instead
@import "themes16/southstreet/ui.all.css";
@import "css/ui-southstreet.datepick.css";
*/
</style>
<script type="text/javascript" src="scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="scripts/jquery.miniColors.js"></script>
<script type="text/javascript" src="scripts/jquery.miniColors2.js"></script>
<script type="text/javascript" src="calendar/jquery.datepick.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>



<script> 
$(document).ready(function(){
  $("#flip").click(function(){
    $("#panel").slideToggle("slow");
  });
});
</script>
</head>



<body topmargin="0" leftmargin="0" bgcolor="#CCCCCC">

<script type="text/javascript" src="swfobject.js"></script>
<script LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=600,left = 340,top = 180');");
}
</script>
<script type="text/javascript">
$(function() {
//  $.datepick.setDefaults({useThemeRoller: true});
    $('#date1').datepick();
    $('#date2').datepick();
    $('#date3').datepick();
    $('#date4').datepick();
    $('#date0').datepick();
});

function showDate(date) {
    alert('The date chosen is ' + date);
}


function limitText(limitField, limitCount, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } else {
        limitCount.value = limitNum - limitField.value.length;
    }
}
</script>


<table align="center" width="1000px" cellpadding="5" cellspacing="0" border="0" bgcolor="#FFFFFF">
<tr>
    <td colspan="2" align="center" valign="top" style="padding:0px;"><img src="images/logo.png" width="400"></td>
</tr>
<tr>
    <td align="right" valign="middle" bgcolor="#FFFFFF" colspan="2">
        <div style="width:100px; overflow:hidden">
        <a href="index.cfm?ACTION=LOGOUT">Log Out</a>
        </div>
    </td>
    </td>
</tr>
<tr>
    <td align="left" valign="top" width="250" style="padding-left:10px; border-right:1px solid #cccccc" bgcolor="#FFFFFF">
        <table width="100%" align="left" bgcolor="#ffffff" cellpadding="1" cellspacing="1">
            <tr>
                <td class="navsub" align="left">Your Account</td>
            </tr>
            <tr>
                <td align="left" bgcolor="#f1f1f1" class="Header3">Quick Information</td>
            </tr>
            <tr>
                <td align="left" class="Copy" id="LogoutBlue">
                <img src="images/logo.jpg" align="middle"><br>
                <font class="Copy">Username:</font> demo<br>
                <font class="Copy">Name:</font> Demo Login<br>
                <font class="Copy">Current Language:</font> English <img src="../images/flags/A22921BD-0055-9C1B-F9C07345BEF072E7.png" align="absmiddle" /><br>
                <font class="Copy">Mode:</font> Live Mode<br>
                </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>


            <tr>
                <td class="nav-button">

                    <A href="company_amend2.cfm">Manage Company</A>
                </td>
            </tr>
            <tr>
                <Td>&nbsp;</Td>
            </tr>
            <tr>
                <td class="nav-button">
                    <A href="vendor_add.cfm">Setup New Vendor</A>
                    <A href="vendor_amend.cfm">Manage Vendors</A>
                </td>
            </tr>
            <tr>
                <Td>&nbsp;</Td>
            </tr>

            <tr>
                <td class="nav-button">
                    <A href="inv_new.cfm">Setup New Invoice</A>
                    <A href="inv_amend.cfm">Manage Invoices</A>
                    <A href="inv_delete.cfm">Delete Invoices</A>
                </td>
            </tr>
            <tr>
                <Td>&nbsp;</Td>
            </tr>

            <tr>
                <td class="nav-button">
                    <A href="user_add.cfm">Setup New User</A>
                    <A href="user_amend.cfm">Manage Users</A>
                    <A href="user_delete.cfm">Delete Users</A>
                </td>
            </tr>
            <tr>
                <Td>&nbsp;</Td>
            </tr>

            <tr>
                <Td>&nbsp;</Td>
            </tr> 
                <Td>&nbsp;</Td>
            </tr>


        </table>
    </td>
    <td valign="top" width="800px" align="center" bgcolor="#ffffff">



<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
var currentItem = 1;
$('#addnew').click(function(){
currentItem++;
$('#items').val(currentItem);
var strToAdd = '<tr><td class="Copy" valign="top">Item Name:</td><td><input type="text" name="Itemname'+currentItem+'" id="Itemname'+currentItem+'" required="yes" message="Please enter a Name" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Item Description:</td><td><input type="text" name="ItemDesc'+currentItem+'" id="ItemDesc'+currentItem+'" required="yes" message="Please enter a Description" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Quantity</td><td><input type="text" name="Quantity'+currentItem+'" id="Quantity'+currentItem+'" required="yes" message="Please enter a Quantity" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Product Code:</td><td><input type="text" name="Code'+currentItem+'" id="Code'+currentItem+'" required="yes" message="Please enter a Code" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Price:</td><td><input type="text" name="Price'+currentItem+'" id="Price'+currentItem+'" required="yes" message="Please enter a Price" class="TextBlock"></td></tr>';
  $('#data').append(strToAdd);

 });
 });

 //]]>
 </script>


<table border="0" cellpadding="0" cellspacing="1" width="100%" class="Border" align="center">
<tr>
    <td class="CopyWhite" align="left" background="images/tab_bg.gif" colspan="2">Add a new invoice</td>
</tr>



        <form method="post" action="inv_new.cfm" enctype="multipart/form-data">
            <tr>
                <td class="Copy" valign="top">Products/Line Items:</td>
                <td>
                </td>
            </tr>
            <tr>
            <td colspan="2">
            <table border="0" id="data" cellpadding="0" cellspacing="1" width="100%" class="Border" align="center">
            <tr>
                <td class="Copy" valign="top">Item Name:</td>
                <td>
                    <input type="text" name="Itemname1" id="Itemname1" required="yes" message="Please enter a Name" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Item Description:</td>
                <td>
                    <input type="text" name="ItemDesc1" id="ItemDesc1" required="yes" message="Please enter a Description" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Quantity</td>
                <td>
                    <input type="text" name="Quantity1" id="Quantity1" required="yes" message="Please enter a Quantity" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Product Code:</td>
                <td><input type="text" name="Code1" id="Code1" required="yes" message="Please enter a Code" class="TextBlock"></td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Price:</td>
                <td><input type="text" name="Price1" id="Price1" required="yes" message="Please enter a Price" class="TextBlock"></td>
            </tr>
            </table>
            </td>
            </tr>
            <tr>
                <td>
                <input type="Submit" name="Submit" value="Submit" class="submitbutton">
                <input type="button" id="addnew" name="addnew" value="Add new item" />
                <input type="hidden" id="items" name="items" value="1" />
                <input type="hidden" name="step" value="4" />
                <input type="hidden" name="invid" value="33" />
                </td>
            </tr>
        </form>


    </td>
</tr>
<tr>
    <td align="right" colspan="2" valign="top"><img src="images/footer.png"></td>
</tr>
</table>
</body>
</html>

我注意到隐藏的项目的值正确更新但我看不到任何其他行

我还注意到,当我查看页面源时,只有一个行项,所以我不确定问题是否与我的脚本有关

请参阅下面的我的cfdump(我添加了4行项目):

enter image description here

检查请求:

------WebKitFormBoundaryZEDCIVZAMPMo4mt4
Content-Disposition: form-data; name="Itemname1"

1
------WebKitFormBoundaryZEDCIVZAMPMo4mt4
Content-Disposition: form-data; name="ItemDesc1"

1
------WebKitFormBoundaryZEDCIVZAMPMo4mt4
Content-Disposition: form-data; name="Quantity1"

1
------WebKitFormBoundaryZEDCIVZAMPMo4mt4
Content-Disposition: form-data; name="Code1"

1
------WebKitFormBoundaryZEDCIVZAMPMo4mt4
Content-Disposition: form-data; name="Price1"

1
------WebKitFormBoundaryZEDCIVZAMPMo4mt4
Content-Disposition: form-data; name="Submit"

Submit
------WebKitFormBoundaryZEDCIVZAMPMo4mt4
Content-Disposition: form-data; name="items"

2
------WebKitFormBoundaryZEDCIVZAMPMo4mt4
Content-Disposition: form-data; name="step"

4

当我在firefox上查看源代码时,我得到以下内容(我添加了4个订单项):

<form method="post" action="inv_new.cfm" enctype="multipart/form-data"></form>
            <tr>
                <td class="Copy" valign="top">Products/Line Items:</td>
                <td>
                </td>
            </tr>
            <tr>
            <td colspan="2">
            <table id="data" class="Border" width="100%" align="center" border="0" cellpadding="0" cellspacing="1">
            <tbody><tr>
                <td class="Copy" valign="top">Item Name:</td>
                <td>
                    <input name="Itemname1" id="Itemname1" required="yes" message="Please enter a Name" class="TextBlock" type="text">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Item Description:</td>
                <td>
                    <input name="ItemDesc1" id="ItemDesc1" required="yes" message="Please enter a Description" class="TextBlock" type="text">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Quantity</td>
                <td>
                    <input name="Quantity1" id="Quantity1" required="yes" message="Please enter a Quantity" class="TextBlock" type="text">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Product Code:</td>
                <td><input name="Code1" id="Code1" required="yes" message="Please enter a Code" class="TextBlock" type="text"></td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Price:</td>
                <td><input name="Price1" id="Price1" required="yes" message="Please enter a Price" class="TextBlock" type="text"></td>
            </tr>
            <tr><td class="Copy" valign="top">Item Name:</td><td><input name="Itemname2" id="Itemname2" required="yes" message="Please enter a Name" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Item Description:</td><td><input name="ItemDesc2" id="ItemDesc2" required="yes" message="Please enter a Description" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Quantity</td><td><input name="Quantity2" id="Quantity2" required="yes" message="Please enter a Quantity" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Product Code:</td><td><input name="Code2" id="Code2" required="yes" message="Please enter a Code" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Price:</td><td><input name="Price2" id="Price2" required="yes" message="Please enter a Price" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Item Name:</td><td><input name="Itemname3" id="Itemname3" required="yes" message="Please enter a Name" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Item Description:</td><td><input name="ItemDesc3" id="ItemDesc3" required="yes" message="Please enter a Description" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Quantity</td><td><input name="Quantity3" id="Quantity3" required="yes" message="Please enter a Quantity" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Product Code:</td><td><input name="Code3" id="Code3" required="yes" message="Please enter a Code" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Price:</td><td><input name="Price3" id="Price3" required="yes" message="Please enter a Price" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Item Name:</td><td><input name="Itemname4" id="Itemname4" required="yes" message="Please enter a Name" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Item Description:</td><td><input name="ItemDesc4" id="ItemDesc4" required="yes" message="Please enter a Description" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Quantity</td><td><input name="Quantity4" id="Quantity4" required="yes" message="Please enter a Quantity" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Product Code:</td><td><input name="Code4" id="Code4" required="yes" message="Please enter a Code" class="TextBlock" type="text"></td></tr><tr><td class="Copy" valign="top">Price:</td><td><input name="Price4" id="Price4" required="yes" message="Please enter a Price" class="TextBlock" type="text"></td></tr></tbody></table>
            </td>
            </tr>
            <tr>
                <td>
                <input name="Submit" value="Submit" class="submitbutton" type="Submit">
                <input id="addnew" name="addnew" value="Add new item" type="button">
                <input id="items" name="items" value="4" type="hidden">
                <input name="step" value="4" type="hidden">
                </td>
            </tr>

似乎没有形式关闭标签

请告知我如何解决此问题

提前谢谢

1 个答案:

答案 0 :(得分:0)

好的,我解决这个问题的方法是

page.cfm:

<cfif form.step eq 3>
    <form method="post" action="inv_new.cfm" enctype="multipart/form-data"> 
</cfif>
<table border="0" cellpadding="0" cellspacing="1" width="100%" class="Border" align="center">
<tr>
    <td class="CopyWhite" align="left" background="images/tab_bg.gif" colspan="2">Add a new invoice</td>
</tr>

<cfoutput>

<cfif form.step eq 3>
        <!---WRITE DATA TO TBLINV--->
        <cfquery name="write_inv" datasource="#application.db#" result="test">
            INSERT INTO tblpassInv
            (INVVENDORID,INVREF,INVNAME,INVLNAME,INVTEL,INVEMAIL,INVADDR1,INVADDR2,INVCITY,INVREGION,INVCOUNTRY,INVZIP,INVCOMPANY,INVCREATEDBY,INVDATECREATED,INVACTIVE,INVSEND)
            VALUES
            (#form.vendor#,'#form.REFNUM#','#form.NAME#','#form.LNAME#','#form.TEL#','#form.EMAIL#','#form.ADDR1#','#form.ADDR2#','#form.CITY#','#form.REGION#','#form.COUNTRY#','#form.ZIP#',#session.companyid#,#session.adminid#,#createodbcdatetime(now())#,1,0)
        </cfquery>
        <cfset NewPrimaryKey = test.GENERATED_KEY>
        <!---<cfinclude template="inv_amend_prods_new.cfm">--->
        <tr>
        <td>
        <table  id="data">
            <tr>
                <td class="Copy" valign="top">Products/Line Items:</td>
                <td>
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Item Name:</td>
                <td>
                    <input type="text" name="Itemname1" id="Itemname1" required="yes" message="Please enter a Name" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Item Description:</td>
                <td>
                    <input type="text" name="ItemDesc1" id="ItemDesc1" required="yes" message="Please enter a Description" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Quantity</td>
                <td>
                    <input type="text" name="Quantity1" id="Quantity1" required="yes" message="Please enter a Quantity" class="TextBlock">
                </td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Product Code:</td>
                <td><input type="text" name="Code1" id="Code1" required="yes" message="Please enter a Code" class="TextBlock"></td>
            </tr>
            <tr>
                <td class="Copy" valign="top">Price:</td>
                <td><input type="text" name="Price1" id="Price1" required="yes" message="Please enter a Price" class="TextBlock"></td>
            </tr>
            </table>
            </td>
            </tr>
            <tr>
                <td>
                <input type="Submit" name="Submit" value="Submit" class="submitbutton">
                <input type="button" id="addnew" name="addnew" value="Add new item" />
                <input type="hidden" id="items" name="items" value="1" />
                <input type="hidden" name="step" value="4" />
                <input type="hidden" name="invid" value="#NewPrimaryKey#" />
                </td>
            </tr>
    </cfif>

footer.cfm

<tr>
    <td align="right" colspan="2" valign="top"><img src="images/footer.png"></td>
</tr>
</table>

<cfif form.step eq 3>
    </form> 
</cfif>
</body>
</html>
相关问题