Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Processing Within One Form

Status
Not open for further replies.

techshoot

Programmer
Aug 25, 2001
173
US
I have a form that is created with a database query using data from a previous form. I need to add information to one field and then process it when the user selects a button within the same form and can't seem to get the procedure to run on the click. I have attached the primary code portion below, can anyone tell me what I am doing wrong.

<HTML><HEAD><TITLE>Page Title</TITLE></HEAD>

<%Sub ValPost()
'processing done here but a msgbox for testing and isn't working
msgbox &quot;Run&quot;
End Sub %>

<% ' Database connection code here %>

<% ' Get Passed Data From Previous Form
arySell=Split(Request.Form(&quot;Previous&quot;),&quot;,&quot;)
%>

<FORM>
<TABLE width=&quot;640&quot; border = 1 cellpadding=2 cellspacing=0 rules=rows frame=void>

<% For intCount = 0 to UBOUND(arySell) %>

<% Set oRs = oConn.Execute(&quot;SELECT Type, Description, Marked, Cost, Source FROM tblData WHERE Index = &quot; & arySell(intCount))

<TABLE width=&quot;640&quot; border = 1 cellpadding=2 cellspacing=0 rules=rows frame=void>

' ShowValues is Function for Formatting text and numeric data
sType = ShowValues(oRs(&quot;Type&quot;),0)
sDesc = ShowValues(oRs(&quot;Description&quot;),0)
nMarked = ShowValues(oRs(&quot;Marked&quot;),2)
nCost = ShowValues(oRs(&quot;Cost&quot;),2)
sSource = ShowValues(oRs(&quot;Source&quot;),0)
%>
<tr>
<input type=hidden name=&quot;Index&quot; value= <%= arySell(intCount) %>>
<td><%= sType %></td>
<td><%= sDesc %></td>
<td><%= nMarked %></td>
<td><%= nCost %></td>
<td><%= sSource %></td>
<td><input type=text name=&quot;Sell&quot; value=0>
</tr>
<% Next %>

<tr>
<td colspan=6 align=left><input type=&quot;button&quot; On_Click=&quot;ValPost&quot; value=&quot;Submit&quot;></td>
</tr>

<% 'Close Recordset and Database Here
oRs.close
oConn.close
%>

</TABLE>
</FORM>

<%
Function ShowValues(vData, nType)

Select Case nType
Case 0
If IsNull(vData) Then
ShowValues = &quot; &quot;
else
ShowValues = vData
End If
Case 1
If IsNull(vData) Then
ShowValues = 0
Else
ShowValues = vData
End If
Case 2
If IsNull(vData) Then
ShowValues = FormatNumber(0,2,0,0,0)
Else
ShowValues = FormatNumber(vData,2,0,0,0)
End If

End Select
End Function
%>

</BODY>
</HTML>


 
The problem is that your are attempting to run server side code after a client side event. Once the server has exected the ASP code and sends the contents of the page to the client it is done and gone. In order to execute an ASP script you will need to submit back to the server for a new file (or the same one).
-Tarwn &quot;The problem with a kludge is eventually you're going to have to back and do it right.&quot; - Programmers Saying (The Wiz Biz - Rick Cook)
&quot;Your a geek!&quot; - My Girlfriends saying
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top