I am having a problem with a form! I need to be able to
pull information from one table when the page loads and
update another table after I have made changes but the
second time the page loads I want to load the information
from the second table and not from the origional location.
How do I do something like this?
See the code below! I have added a whole load of comments!
Thanks for any help!
..: CODE :.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<%'Submits the updated info to an asp update page%>
<script>
function changetax () {
document.forma.task.value = "CT";
document.forma.submit ();
</script>
<%
dim rs, tmprs, conn, sql
dim procid, tableid, symbol
dim task, menu, exrate, currname
set conn = server.createobject("adodb.connection")
conn.open (application("proc"))
procid = request("procid")
task = request("task")
sql = "select * from tblpurchase where procid = '" &
procid & "';"
set rs = conn.execute(sql)
sql = "select * from tblCurrency where CurrencyID = " & rs
("CurrencyID") & ";"
set tmprs = conn.execute(sql)
symbol = tmprs("CurrencySymbol")
exrate = tmprs("ExRate")
TaxAmount = tmprs("TaxAmt")
%>
</head>
<body>
<form name="forma" action="dosupplies.asp" method="post">
<font style="font-size:12pt;"><b>New item</b></font>
<table cellpadding=3 cellspacing=0 border=0>
<tr><td valign="top"><b>Description</b></td>
<td colspan=3><textarea name="description0" cols="50"
rows="2"></textarea></td>
</tr>
<tr>
<td valign="bottom"><b>Qty</b></td>
<td valign="bottom"><b>Unit type</b></td>
<td valign="bottom"><b>Cost</b></td>
<td valign="bottom" align="center"><b>(%)
<br>Discount</b></td>
</tr>
<tr><td><input name="quan0" value="1" size=4></td>
<td><select name="unit0">
<% while not alphars.eof %>
<option value="<%=alphars("unit")%>"><%=alphars
("unit")%> (<%=alphars("unitdesc")%>)
<% alphars.movenext
wend
alphars.movefirst
%></select></td>
<td><input name="unitcost0" value="0" size=10></td>
<td><input name="disc0" value="0" size=5></td>
<td colspan=1>
<input type="button" value="add this item"
onclick="javscript:newitem();">
<% if step > 0 then %>
<input type="button" value="Next (no more items)
" onclick="javascript:doit();"><br><% end if %>
</td>
</tr>
</table>
<!--- Current Added items --->
<hr>
<font style="font-size:12pt;"><b>Current line
items</b></font>
<% if not tmprs.eof then %>
<table cellpadding=3 cellspacing=0 border=0>
<% count = 0
while not tmprs.eof
count = count + 1
subtotal = tmprs("Quantity") * tmprs("UnitCost") %>
<tr><td valign="bottom"><b>#</b></td>
<td valign="bottom"><b>Qty</b></td>
<td valign="bottom"><b>Unit type</b></td>
<td valign="bottom"><b>Cost</b></td>
<td valign="bottom" align="center"><b>(%)
<br>Discount</b></td>
<td valign="bottom"
align="center"><b>Total<BR>Discount</b></td>
<td valign="bottom" align="center"><b>Tax</b></td>
<td valign="bottom" align="center"><b>Total</b></td>
</tr>
<tr><td><%=tmprs("itemno")%></td>
<td><input name="quan<%=count%>" value="<%=tmprs
("Quantity")%>" size=4></td>
<td><select name="unit<%=count%>">
<% while not alphars.eof %>
<option value="<%=alphars("unit")%>" <%if
alphars("unit")=tmprs("unit") then response.write
("SELECTED")%>><%=alphars("unit")%> (<%=alpha rs
("unitdesc")%>)
<% alphars.movenext
wend
alphars.movefirst
'Adds all unit costs together to provide a subtotal
Pdiscount=tmprs("Disc")
Tdiscount=formatnumber((subtotal) / 100 * Pdiscount)
Ttax=((subtotal-Tdiscount)/100) * TaxAmount
totalcost=(subtotal-Tdiscount)+Ttax
%>
</select>
</td>
<td><input name="unitcost<%=count%>" value="<%=tmprs
("UnitCost")%>" size=10></td>
<td><input name="disc<%=count%>" value="<%
=Pdiscount%>" size=5></td>
<td align="center"><%=Tdiscount%></td>
<td align="center"><%=Ttax%></td>
<td align="right"><b><%=formatnumber(totalcost)%</b></td> <td>
<input type="button" value="update"
onclick="javscript:updateitem(<%=count%>,<%=tmprs
("supplyid")%>);">
<input type="button" value="delete"
onclick="javscript:killitem(<%=count%>,<%=tmprs
("supplyid")%>,<%=tmprs("itemno")%>);">
</td>
</tr>
<tr><td colspan=2 valign="top"><b>Description</b></td>
<td colspan=4><textarea name="description<%=count%>"
cols="50" rows="2"><%=tmprs("Description")%</textarea></td>
</tr>
<% tmprs.movenext
wend
%>
</table>
<% else %>
<br>Currently there no line items.
<% end if %>
<%
'See below
'Tax Percentage allows the user to change the
'tax percentage to an alternative rather than the
'default taken from the table tblcurrencies, however when
'this is done it shouldn't change the value in the
'tblcurrencies table but rather in the tblpuchase.
'This is why the second time the page loads it sould no
'longer use the tblcurrencies table for it's information
'but rather the tblpurchase table.
%>
<hr>
<font style="font-size:12pt;"><b>Extra costs for this
procurement</b></font>
<table cellpadding=3 cellspacing=0 border=0>
<tr><td
valign="top"><b>Tax Percentage:</b> </td><td
valign="top">
<input name="taxamt" value="<%=TaxAmount%>" size=3>%
</td></tr>
<tr><td
valign="top"><b>Shipping Cost:</b> </td><td
valign="top">
<input name="ShipCost" value="<%=rs("ShipCost")%>"
size=12></td></tr>
<tr><td valign="top"><b>Surcharges:</b></td> <td
valign="top">
<input name="SurCharge" value="<%=rs("SurCharge")%>"
size=12></td></tr>
</tr>
<tr><td></td><td><input type="button" value="update costs
changes" onclick="javascript:changetax();">
</td></tr>
</table>
<% set tmprs = nothing %>
<% set alphars = nothing %>
</body>
</html>