dcsimg

Creating Dynamic Forms Page 5

By ServerWatch Staff (Send Email)
Posted Jan 11, 1999


This page verifies the transaction doesnt already exist, then inserts it into the tran table. Then we create a form with the number of components the transaction needs and passes it on to the 3rd form.

<%

SESSION("INDEX") = REQUEST.FORM("INDEX")
SESSION("TYPE") = REQUEST.FORM("TYPE")
'we set some session varaibles so we have them available for the next page

MY_type = CInt(SESSION("type"))
session("FT") = request.form("ft")
FT = CInt(SESSION("FT"))
session("sub") = request.form("sub")
MY_SUB = CInt(SESSION("SUB"))
Session("RPT") = Request.Form("RPT")
RPT = SESSION("RPT")
SESSION("NAME") = REQUEST.FORM("NAME")

Set count = Server.CreateObject("ADODB.Connection")
DB_PATH = SERVER.MAPPATH("/TDOM/DB")
CONNECT_STR = "FILEDSN="&DB_PATH&"\DB.DSN;" & _
"DBQ=" & DB_PATH & "\WEBDB.MDB;"
count.Open CONNECT_STR
set countrs = Server.CreateObject("ADODB.RecordSet")
'first see if the tran already exists
SQL = "SELECT * FROM TRAN WHERE TR_NAME = '" & REQUEST.FORM("NAME") & "'"
countrs.Open sql, count, 3 , 3, 1
IF COUNTRS.RECORDCOUNT > 0 THEN
    RESPONSE.WRITE "TRAN ALREADY EXISTS, USE THE EDIT TRANSACTION"
    RESPONSE.END 
'response.end ends the transaction
END IF
'insert the transaction into the tran set
SQL = "INSERT INTO TRAN (TR_NAME, TR_GROUP, TR_SUB_GROUP," & _
" TR_CODE, TR_FILE_TYPE" & _
") VALUES ('" & REQUEST.FORM("NAME") & "', " & MY_TYPE & ", " & my_SUB & _
", '" & RPT & "', " & FT & ")"
countrs.close
countrs.Open sql, count, 3 , 3, 1 
' do a select to find the unique id assigned
SQL = "SELECT * FROM TRAN WHERE TR_CODE = '" & RPT & "'"
countrs.Open sql, count, 3 , 3, 1
SESSION("NEW_TRAN_ID") = COUNTRS.FIELDS("TR_ID")
'set the session var
COUNTRS.CLOSE

%>

<head>
<title>Add of the <%=session("name")%> transaction</title>


<form method="post" action = "new_tran3.asp" >

<%
i = CInt(SESSION("INDEX"))
'here we have to create 3(x) number of input boxes, where x is the number of
'indexes from the last posting form
. Each index will have 3 input boxes, the first for the name of the 'component, the second for the position and the last for the maximum length.
j = 1
do while j < i + 1 %>

<p>COMPONENT <%=j%>:<br>
NAME:<input type="text" name="N<%=j%>" size="20">
&nbsp;&nbsp; POSITION<input type="text"
name="P<%=j%>" size="7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
LENGTH<input type="text" name="L<%=j%>"size="7"></p>
<%
j = j + 1
loop
%>

<center><p><input type="submit" value="Submit" name="B1"><input
type="reset" value="Reset" name="B2"></p></center><BR><HR>



Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.


 

 


Thanks for your registration, follow us on our social networks to keep up-to-date