Creating Dynamic Forms Page 3

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


'This page generates a form page from the database set components.
'Each component has contains a description position and max length

<%
SESSION("TRAN") = REQUEST("TRAN_ID")

THIS_TRAN = SESSION("TRAN")
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")
SQL = "SELECT TR_NAME, TR_FILE_TYPE FROM TRAN WHERE " & _                             "TR_ID="&THIS_TRAN

countrs.Open sql, count, 3 , 3, 1
IF COUNTRS.EOF THEN  
'cant find any transactions
     RESPONSE.WRITE ("NO TRANSACTION EXISTS!")
     RESPONSE.END   
'response.end stops the asp here
ELSE
'save off the 2 needed fields from the DB
TRAN_NAME = countrs.Fields("TR_NAME")
TRAN_FT = COUNTRS.FIELDS("TR_FILE_TYPE")
COUNTRS.CLOSE
%>

<head>
<title><%=TRAN_NAME%></title>


<form method="POST" action="TRAN_RS.ASP">
<%
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

'create a drop down of the possible insurance types
set countrs = Server.CreateObject("ADODB.RecordSet")
SQL = "SELECT * FROM GROUPS"
countrs.Open sql, count, 3 , 3, 1
FIRST_TIME = 1
IF NOT COUNTRS.EOF THEN %>


<center>INSURANCE TYPE <SELECT NAME = "TYPE" SIZE = "1">
<% DO WHILE NOT COUNTRS.EOF %>
<OPTION
<%
IF FIRST_TIME = 1 THEN
       RESPONSE.WRITE " SELECTED "  
'make the first type the default
       FIRST_TIME = 0
END IF %>

VALUE = "<%=COUNTRS.FIELDS("tran_RPT")%>"><%=COUNTRS.FIELDS("tran_group_name")%></OPTION>
<%
COUNTRS.MOVENEXT
LOOP  
'loop thru all the groups
COUNTRS.CLOSE %>
</select>

<%end if %>


</SELECT></CENTER>
<%
SQL = "SELECT * FROM COMPONENTS WHERE TR_TRAN_ID = "& THIS_TRAN & " ORDER BY TR_POSITION"
countrs.Open sql, count, 3 , 3, 1
%>

<table border="0" width="100%" height="100%">
<%                      ' create a table 2 columns wide of all the components
TABLE = 0
DO WHILE NOT COUNTRS.EOF
%>


<% IF TABLE = 0 THEN
TABLE = 1 %>

<TR>
<%
ELSE
TABLE = 0
END IF %>

<TD>
<%
RESPONSE.WRITE COUNTRS.FIELDS("TR_NAME") & ":<br> " %>

<input type="text" name="FIELD<%=COUNTRS.FIELDS("TR_POSITION")%>" size="
<% TEMP = CINT(COUNTRS.FIELDS("TR_LENGTH")) 'create box 5 larger than the max
TEMP = TEMP + 5
RESPONSE.WRITE TEMP %>
" MAXLENGTH =   'create a max length "<%=COUNTRS.FIELDS("TR_LENGTH")%>"></TD>
<%
COUNTRS.MOVENEXT
IF TABLE = 0 THEN %>

</TR>
<%
END IF

LOOP


END IF
%>

</TABLE>
<CENTER><input type="submit" value="Submit" name="B1">
</FORM><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