<%
'Get item details for a place from database
VB function to retrieve data from SQL server
ls_items = session("doe_job"

.getsubjobtype(session "doe_job"

.location_id)
%>
'condition when no item
<% if ls_items="" then
%>
<%else
'Split all items into saperate row
each_item_inf = split(ls_items, "|", -1, 1)
ll_row=ubound(each_item_inf)-1
%>
<%
dim ar1()
redim ar1(ll_row)
for i=0 to ll_row
'Divide item information into saperate fields
each_field_inf = split(each_item_inf(i),"^", -1, 1)
'Make checkbox and quantity box names for each table row
chk_name = "item_check" + cstr(i)
qty_name = "quantity" + cstr(i)
cost_name = "cost_name" + cstr(i)
avail_name = "avail" + cstr(i)
unit_name = "unit" + cstr(i)
'Get already ordered items from database
if action = "previous" then
dim ar3
ar3 = session("ar()"

else
pass_str = "jobno='" & session("doe_job"

.jobno & "' and item_id =" & each_field_inf(7)
'Another VB function
ordered_item = doe_lookup.getlookup( "job_details","item_qty","item_id", pass_str)
oredered_item_id = split(doe_lookup.getDisplaycol , "|", -1, 1)
ordered_quantity = split(doe_lookup.getDatacol, "|", -1, 1)
if ordered_item > 0 then
ar1(i)= ordered_quantity(0)
else
ar1(i) = 0
end if
end if
if action = "previous" then
oldq =cstr( ar3(i))
else
if ordered_item > 0 then
oldq = cstr(ordered_quantity(0))
else
oldq = cstr(0)
end if
end if
%>
<input type =hidden name = old_qty value =<%Response.Write(oldq)%> >
<TR>
<INPUT name=<%=chk_name %> type=checkbox tabIndex=40 value="<% Response.Write(each_field_inf(7))%>"
<% if action = "previous" then
if ar3(i)>0 then %>
checked
end if
else
if ordered_item > 0 then
checked
end if
end if %> >
<%response.write(each_field_inf(0))
response.write(each_field_inf(1))
response.write(each_field_inf(2))
response.write(each_field_inf(3)) %>
<input type = hidden name =<%= cost_name %> value = <%response.write(each_field_inf(3)) %> >
<input type = hidden name=<%= avail_name %> value = <%response.write(each_field_inf(4)) %>>
<input type = hidden name=<%= unit_name %> value = <%response.write(each_field_inf(2)) %>>
<input tabIndex=45 name =<%=qty_name%> type =text size=8
<%if action = "previous" then
if ar3(i)>0 then
Response.Write("value = " & ar3(i))
end if
else
if ordered_item > 0 then
Response.Write("value = " & ordered_quantity(0))
end if
end if %>
onblur = "javascript:validate(<%=i%>,<%=qty_name%>,<%=qty_name%>.value,<%= cost_name %>.value,<%= avail_name %>.value,<%= unit_name %>.value,<%= chk_name %>.checked,<%=chk_name%>,<%= ll_row%>,old_qty(<%= i %>).value)">
<% total_amount = 0
if action = "previous" then
if ar3(i)>0 then
total_amount = cdbl(ar3(i))*cdbl(each_field_inf(3))
end if
else
if ordered_item > 0 then
total_amount = cdbl(ordered_quantity(0))*cdbl(each_field_inf(3))
end if
end if
%>
<SCRIPT>
tot = cal_total(<%= total_amount %>);
if (tot == "0.00"

{
tot = "";
}
else
{
tot = "$"+ tot;
}
document.write ("<input readonly name =total type =text size=8 value = "

;
document.write (tot);
document.write (">"

;
</SCRIPT>
<%
next
if action = "previous" then
else
session("ar()"

=ar1
end if
%>