GuidesCreating Dynamic Forms Page 6

Creating Dynamic Forms Page 6

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.




This page takes each component of the the new_tran2.asp page and
inserts it into the components table. The trick is traversing the
request collection since the number of request items can be
different for any transaction. Also the submit and reset buttons are
part of the collection sent to this page, so we must make sure we
have logic to handle or else they will be inserted into the
database.

NEW TRANSACTION <font color="#ff0000"></font>

NEW
TRANSACTION

Set count =
Server.CreateObject(“ADODB.Connection”)
DB_PATH =
SERVER.MAPPATH(“/DB”)
CONNECT_STR  =  “FILEDSN=” &
DB_PATH & “DB.DSN;” & _
“DBQ=” & DB_PATH &
“WEBDB.MDB;”
count.Open CONNECT_STR
‘get a connection to the db
set countrs =
Server.CreateObject(“ADODB.RecordSet”)
NBR_OF_ITEM = 0
‘every 3 items makes one
component

For Each item In
Request.Form() 
‘traverse the
Request items

      if (item
“B1”) AND (item “B2”) then 
‘dont process the buttons
         
NBR_OF_ITEM = NBR_OF_ITEM +
1
          IF
MID(ITEM,1,1) = “N”
THEN
              
MY_NAME =
(request.form(item))
         
ELSE
          IF
MID(ITEM,1,1) = “P”
THEN
              
MY_POSITION = (request.form(item))

         
ELSE
             
MY_LENGTH = request.form(item)

          END
IF
          IF
NBR_OF_ITEM = 3
THEN
             
NBR_OF_ITEM = 0 

          END
IF
          END IF

‘every 3 items do an insert into
components

         
IF NBR_OF_ITEM = 0
THEN
              
SQL = “INSERT INTO COMPONENTS (TR_TRAN_ID, TR_POSITION, ” & _
                
“TR_LENGTH,” &
_
              
“TR_NAME) VALUES (” & SESSION(“NEW_TRAN_ID”) & “, ” &
_
              
MY_POSITION & “, ” & MY_LENGTH &”, ‘” & MY_NAME
& “‘)”
  

             
countrs.Open sql, count, 3 , 3,
1
          END
IF
        END
IF
Next
%>

COMPONENTS HAVE BEEN
ADDED!
Working
example

Get the Free Newsletter!
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.
Get the Free Newsletter!
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.

Latest Posts

Related Stories