I have 2 screens. 1st screen has input box (invoice#). After input invoice# and click submit, then it go to 2nd asp. The 2nd asp retrieve data thru CGI programs and load into table. On 2nd page here user may edit data or add if it's new invoice. I want the 2nd page to submit itself when user click update. After update/add then go back to first screen.
Problem is when I click update, my table got reset and it stay on the same page. I'm very new here. I'm not sure if what I'm doing is make sense or not. So I'm welcome any comment & suggestions. Please help.
Here is my 2nd screen (2 asp files). I don't think I need to show 1st screen.
*note: I only code sql for adding. I will do the update once I got the problem fix.
Thanks in advance.
-- mv_ap_detail.asp--
-- mv_ap_detailhelper.asp--
Problem is when I click update, my table got reset and it stay on the same page. I'm very new here. I'm not sure if what I'm doing is make sense or not. So I'm welcome any comment & suggestions. Please help.
Here is my 2nd screen (2 asp files). I don't think I need to show 1st screen.
*note: I only code sql for adding. I will do the update once I got the problem fix.
Thanks in advance.
-- mv_ap_detail.asp--
Code:
<!-- Include general tracking system functions. -->
<!--#include virtual="/helpers/mv_ap_detailhelper.asp"-->
<html>
<head>
<title>Payable Invoice Maintenance </title>
<link rel="Stylesheet" href="css/style.css" type="text/css">
<script type="text/javascript" defer>
<!--
function ltrim(strIn)
{
var strOut=""
if (!strIn)
{}
else
{
for (intI=0; intI < strIn.length; intI++)
{
if (strIn.charAt(intI) !=" ")
{
strOut = strIn.substring(intI)
break
}
}
}
return strOut
}
function output()
{
if (document.f1.ponum.value=="")
{
alert ("P.O # is Required");
document.f1.ponum.focus();
return false;
}
if (isNaN(ltrim(document.f1.invamt.value)) || ltrim(document.f1.invamt.value)< 0 )
{
alert ("Invalid Invoice Amount Entered. Please Enter an Integer.");
document.f1.invamt.focus();
return false;
}
flag = "1"
[COLOR=red]
document.f1.submit(); [/color]
}
-->
</script>
</head>
<%
// Generates the main header for import tracking pages.
GenerateTrackingHeader ("portrait")
%>
<%
// Generates the subnavigation for import tracking pages.
GenerateTrackingSubNav (0)
%>
<a name="pos1"></a>
<table cellspacing="0" cellpadding="0" border="0" bgcolor="#edecd7">
<form action="mv_ap_detail.asp" method="post" name="f1">
<tr>
<td><img src="images/spacer.gif" width="1" height="360" border="0"></td>
<td><img src="images/spacer.gif" width="10" height="1" border="0"></td>
<td valign="top">
<table cellspacing="0" cellpadding="0" border="0" >
<tr><td colspan="4"><img src="images/spacer.gif" width="701" height="1" border="0"></td></tr>
<tr><td colspan="4"><img src="images/spacer.gif" width="1" height="19" border="0"></td></tr>
<tr>
<td valign="center" class="ver12pxgrn" align="left"><b><%=clientname%></b><td>
<td align="right">
<a class="ver10pxblk">Hello,</a>
<a class="ver10pxred"><b><%=username%>.</b></a>
<a class="ver10pxblk">You are currently logged in.</a>
<a class="ver10pxred" href=logout.asp><b><u>Logout</u></b></a>
</td>
</tr>
<tr><td><img src="images/spacer.gif" width="1" height="10" border="0"></td></tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td colspan="6"><hr></td></tr>
<tr><td><img src="images/spacer.gif" width="1" height="5" border="0"></td></tr>
<tr>
<td width="40%"><font size="+1"><b>Payable Invoice Maintenance</b></font></td>
<td width="5%"><img src="images/spacer.gif" width="1" height="1" border="0"></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td><img src="images/spacer.gif" width="1" height="10" border="0"></td></tr>
<tr>
<td width="125" align="right" class="ver11pxblk"><B>Invoice#</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td class="ver11pxblk"><%=invnumber%></td>
<td class="ver11pxblk" align="right"><b>Inv. Description</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td><input name="invdesc" class="ver11pxblk" type="Text" size="35" maxlength="35" value="<%=description%>"></td>
</tr>
<tr><td><img src="images/spacer.gif" width="1" height="10" border="0"></td></tr>
<tr>
<td width="125" align="right" class="ver11pxblk"><B>Inv. Date</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td><input name="invdate" class="ver11pxblk" type="Text" size="10" value="<%=invdate%>"></td>
<td class="ver11pxblk" align="right"><b>Issuer</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td>
<select name="<%=vendorvarname%>" class="ver10pxblk">
<option selected value="none">Select One </option>
<% for j = 0 to numberofvendors - 1 %>
<% if (issuer = mid(vendorcode (j),2,6)) then %>
<option value="<%=vendorcode(j)%>" selected><%=vendorname(j)%></option>
<% else %>
<option value="<%=vendorcode(j)%>"> <%=vendorname(j)%></option>
<% end if %>
<% next %>
</select>
</td>
</tr>
<tr><td><img src="images/spacer.gif" width="1" height="10" border="0"></td></tr>
<tr>
<td width="125" align="right" class="ver11pxblk"><B>Inv. Amount</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td><input name="invamt" class="ver11pxblk" type="Text" size="10" value="<%=invamount%>"></td>
<td class="ver11pxblk" align="right"><b>Due Date</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td><input name="duedate" class="ver11pxblk" type="Text" size="15" value="<%=duedate%>"></td>
</tr>
<tr><td><img src="images/spacer.gif" width="1" height="10" border="0"></td></tr>
<tr>
<td width="125" align="right" class="ver11pxblk"><B>Department#</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td><input name="dept" class="ver11pxblk" type="Text" size="6" maxlength="6" value="<%=department%>"></td>
<td class="ver11pxblk" align="right"><b>P.O.#</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td><input name="ponum" class="ver11pxblk" type="Text" size="20" maxlength="20" value="<%=ponumber%>"></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td><img src="images/spacer.gif" width="1" height="10" border="0"></td></tr>
<tr>
<td width="70%"><img src="images/spacer.gif" width="10" height="1" border="0"></td>
<td width="25%"><input type="Button" name="update" value="update" class="ver12pxgrn" onclick="output()" ></td>
<td width="5%"><img src="images/spacer.gif" width="5" height="1" border="0"></td>
</tr>
<tr><td ><img src="images/spacer.gif" width="1" height="5" border="0"></td></tr>
</table>
<%
// Generates the main content-holder-footer for reports pages.
GenerateReportsSubFooter ()
%>
<!-- End Content -->
<%
// Generates the main footer for import tracking pages.
GenerateTrackingFooter ()
%>
</td>
</tr>
</form>
</table>
</html>
Code:
<!-- Include general tracking system functions. -->
<!--#include virtual="/include/subs.asp"-->
<%
// START OF LOGIC
// Verify user has logged-on.
CheckLogin ()
// Set-up variables.
as400url = "[URL unfurl="true"]http://172.16.1.10/cgi-bin2/xmv020?"[/URL]
clientcode = mid(session ("masteraccount"),1,6)
username = session ("username")
clientname= mid(session ("masteraccount"),7, len(session("masteraccount")))
notauthorizederror = "error.asp?error=notauthorized"
servererror = "error.asp?error=server"
baddateerror = "error.asp?error=baddate"
notnumericerror = "error.asp?error=notnumeric"
apexisterror = "error.asp?error=apexist"
invnumber=Ucase(trim(request("invnumber")))
varmiscinv = "X"
// Verify that the user has authority to view this page.
if (session("showcustomizedinterface") <> "true") then
Response.redirect notauthorizederror
end if
[COLOR=red]
// Output to db file
if strflag > "" then
strinvdate=trim(request("invdate"))
if strinvdate<>"" then
varinvdate=FormatDateCCYYMMDD (strinvdate)
if (varinvdate= "Error") then
Response.redirect baddateerror
end if
strinvdate=mid(varinvdate,5,2) + "/" + mid(varinvdate,7,2) + "/" + mid(varinvdate,3,2)
end if
strduedate=trim(request("duedate"))
if strduedate<>"" then
varduedate=FormatDateCCYYMMDD (strduedate)
if (varduedate= "Error") then
Response.redirect baddateerror
end if
strduedate=mid(varduedate,5,2) + "/" + mid(varduedate,7,2) + "/" + mid(varduedate,3,2)
end if
strdesc=Ucase(trim(request("description")))
strissuer=Ucase(trim(request("vendorcode(j)")))
strdept=Ucase(trim(request("department")))
strponum=Ucase(trim(request("ponum")))
strvendorcode=mid(request("vendorcode(j)"),2,6)
if recordexist = "no" then
sql="select * from cisdtalib.$mvaph where phinv#='"&invnumber&"', phivtp = '"&miscinv&"'"
rsMVAPH.open sql, objconn,1,1
if not rsMVAPH.eof then
response.redirect invoiceexisterror
else
sqll = "insert into cisdtalib.$mvaph(phinv#, phdesc, phivtp, phivdt, phdudt, phiamt, phissu) "
sqll = sqll & "VALUES ('"&invnumber&"','"&strdesc&"', '"&miscinv&"', '"&strinvdate&"', '"&strduedate&"', '"&invamount&"', '"&strvendorcode&"')"
objconn.execute(sqll)
end if
rsMVAPH.close
set rsMVAPH=nothing
newurl = "mv_ap_maint.asp"
Response.redirect newurl
end if
end if
[/color]
// START BUSINESS LOGIC
queryString = as400url + username + "+" + invnumber
Set xmldoc = ReadXMLFromAS400 (queryString)
description = ReadXML (xmldoc, "//description")
invamount = ReadXML (xmldoc, "//invamount")
invdate = ReadXML (xmldoc, "//invdate")
duedate = ReadXML (xmldoc, "//duedate")
issuer = ReadXML (xmldoc, "//issuer")
department = ReadXML (xmldoc, "//department")
ponumber = ReadXML (xmldoc, "//ponumber")
recordexist = ReadXML (xmldoc, "//recordexist")
strReason = ReadXML (xmldoc, "//recordnotavailable")
if (strReason > "") then
nodataerror = "error.asp?error=nodata&reason=" & server.URLEncode(strReason)
Response.redirect nodataerror
end if
// Vendor List
set nodelist = xmldoc.selectNodes("//vendor")
numberofvendors = xmldoc.selectNodes("//vendor").length
dim vendorcode()
dim vendorname()
redim preserve vendorcode(numberofvendors)
redim preserve vendorname(numberofvendors)
i = 0
for each record in nodelist
vendorcode (i) = ReadXML(record,"vendorcode")
vendorname (i) = ReadXML(record,"vendorname")
i = i + 1
next
%>