Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Asp & Javascript Dynamic Rows Example

DZone's Guide to

Asp & Javascript Dynamic Rows Example

·
Free Resource
asp & javascript dynamic rows example


<%
numRecords = 0

if Request.Form.count > 0 then
	' How many rows were submitted?
	numRows = cint( Request.Form("count") ) - 1 
	
	' Dim the arrays
	Response.write Execute( "Dim kbarticle( 100 )" )
	Response.write Execute( "Dim platform( 100 )" )
	Response.write Execute( "Dim desc( 100 )" )
	Response.write Execute( "Dim file( 100 )" )
	Response.write Execute( "Dim fileversion( 100 )" )
	Response.write Execute( "Dim branch( 100 )" )
	Response.write Execute( "Dim reboot( 100 )" )
	Response.write Execute( "Dim mbsa( 100 )" )
	Response.write Execute( "Dim packagename( 100 )" )
	Response.write Execute( "Dim packagesize( 100 )" )
	Response.write Execute( "Dim supercedes( 100 )" )
	Response.write Execute( "Dim save( 100 )" )
	Response.write Execute( "Dim delete( 100 )" )
	
	'fill with the values
		For Each x In Request.Form
			VarString = x & "=""" & Request.Form(x) & """"		
			Response.write Execute( VarString )
		Next
	
	
	'new associative array logic
	Dim RequestVars:Set RequestVars=New AssocArray
	for x=0 to numRows 
		RequestVars( x )("kbarticle") = kbarticle( x )
		RequestVars( x )("platform") = platform( x )
		RequestVars( x )("desc") = desc( x )
		RequestVars( x )("file") = file( x )
		RequestVars( x )("fileversion") = fileversion( x )
		RequestVars( x )("branch") = branch( x )
		RequestVars( x )("reboot") = reboot( x )
		RequestVars( x )("mbsa") = mbsa( x )
		RequestVars( x )("packagename") = packagename( x )
		RequestVars( x )("packagesize") = packagesize( x )
		RequestVars( x )("supercedes") = supercedes( x )
	next
	
	'show some output
	
	for i = 0 to (RequestVars.Count - 1)
		if RequestVars( i )("kbarticle") <> "" then
			strSql = ""
			strSql = "insert into patches (kbarticle,platform,desc,file,fileversion,branch,reboot,mbsa,packagename,packagesize,supercedes) values ("
			strSql = strSql & "'"  & RequestVars( i )("kbarticle")   & "'"
			strSql = strSql & ",'" & RequestVars( i )("platform")    & "'"
			strSql = strSql & ",'" & RequestVars( i )("desc")        & "'"
			strSql = strSql & ",'" & RequestVars( i )("file")        & "'"
			strSql = strSql & ",'" & RequestVars( i )("fileversion") & "'"
			strSql = strSql & ",'" & RequestVars( i )("branch")      & "'"
			strSql = strSql & ",'" & RequestVars( i )("reboot")      & "'"
			strSql = strSql & ",'" & RequestVars( i )("mbsa")        & "'"
			strSql = strSql & ",'" & RequestVars( i )("packagename") & "'"
			strSql = strSql & ",'" & RequestVars( i )("packagesize") & "'"
			strSql = strSql & ",'" & RequestVars( i )("supercedes")  & "'"
			strSql = strSql & ")" + "
" response.write "
" & strSql & "
" else strMessage = strMessage & "KB Article cannot be left blank.
" End If next End If %> MS10-001
MS10-001KB971270Vulnerability in the Embedded OpenType Font Engine Could Allow Remote Code ExecutionCritical    Export to Excel  

<% if numRecords = 0 then %> <% End If %>
No Records Found
<%= strMessage %>
<% if numRecords = 0 then %> <% else %> <% End If %>
<% Class AssocArray Private dicContainer Private Sub Class_Initialize() Set dicContainer=Server.CreateObject("Scripting.Dictionary") End Sub Private Sub Class_Terminate() Set dicContainer=Nothing End Sub Public Function Exists(sName) If Not dicContainer.Exists(sName) Then Exists = "" Else Exists = Item(sName) End If End Function Public Function Count() Count = dicContainer.Count End Function Public Default Property Get Item(sName) If Not dicContainer.Exists(sName) Then dicContainer.Add sName,New AssocArray End If If IsObject(dicContainer.Item(sName)) Then Set Item=dicContainer.Item(sName) Else Item=dicContainer.Item(sName) End If End Property Public Property Let Item(sName,vValue) If dicContainer.Exists(sName) Then If IsObject(vValue) Then Set dicContainer.Item(sName)=vValue Else dicContainer.Item(sName)=vValue End If Else dicContainer.Add sName,vValue End If End Property End Class %>
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}