Wrox Programmer Forums
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 28th, 2003, 10:06 PM
Registered User
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default passing Multidimensional Array Values back to form

hi ..
Is it possible to pass a multidimensional array values[retrieve form the database] back to a form and only display the first record. When a user click a button[left , right] , i will move through the array and display the values on texboxes using the button onclick event.

Problem ..
When a user enter "Ap" in a textbox, i will goto the database and retrieve a whole list of values[industry, address, postalcode, country .. etc] with Company name that begin with "Ap". I will store all the values in an multidimensional array and when user click a left/right button, i will move through he array and retrieve the values and display in textboxes.

Old September 4th, 2003, 03:33 PM
Registered User
Join Date: Sep 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

assuming your using ASP - there are a few methods but you will need to pass the values to, say, hidden form objects and then select the appropriate values to fill in your text boxes.
somthinge like
<input type="hidden" name="name001" value="Company 1" />
<input type="hidden" name="address001" value="Address 1" />
<input type="hidden" name="name002" value="Company 2" />
then use your javascript to populate the text boxes to be displayed.

a word of warning if someone types "%%" as a search pattern it would bring all of the data back from the DB and your page could be downloading for ages

Old June 21st, 2013, 01:59 PM
Registered User
Join Date: Jun 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default insert values in Array to card shop in asp

I have some code that I use in sites to enter values ​​in the array, and store in session. This code is very useful for shopping cart in loja virtual:


Function VetorMonta(Acao,Valor)
'Usamos o case para manipular a ação da função
Select Case Trim(Acao)
Case "Incluir"
'Guarda na variavel Vetor o conteudo da Session
Vetor = Session("GuardaVetor")
'Verifica se a Variavel Vetor é um Array, caso nao for entao definimos ela um Array
If Not IsArray(Vetor) Then Vetor = Array() End if
'Verifica se o Valor que esta sendo inserido já esta no Vetor se estiver entao nao inseri para nao haver duplicidades do vetor
If InStr(Join(Vetor), Valor) = 0 Then
'Este comando ira preservar o vetor e adciona + 1 valor
ReDim preserve Vetor(UBound(Vetor)+1)
Vetor(Ubound(Vetor )) = Valor
'Coloca o conteudo da variavel vetor dentro da Session
Session("GuardaVetor") = Vetor
End if
End Select 'Fim do Case
End Function

Function Incluir_Vetor
'Executa a função que ira criar uma posição do vetor, basta passar a acao e o valor
Call VetorMonta("Incluir",Replace(Request("Valor_Vetor" ),"'",""))
Call VetorMonta("Incluir",Replace(Request("tamanho"),"' ",""))
End Function

Function VisualizaValoresVetor
Response.Write "<table border='2'>"
Response.Write "<tr><td>id</td><td>valor</td>"
Response.Write "</tr>"

For x = 0 To ubound(session("GuardaVetor")) 'ira fazer um laço mostrando todos os vetores criados
Response.Write "<tr><td>" & x & "</td>"
Response.Write "<td>" &session("GuardaVetor")(x) & "</td>"
Response.Write "</tr>"
Response.Write "</table>"

'Verifica se a Session tem alguma posição, se tiver mostra a opção de apagar todos os vetores
If ubound(session("GuardaVetor")) >= 0 Then
Response.Write "<br>" &"<a href='vetor.asp?action=LimpaVetor'>Apagar Tudo</a>" & "<br>" 'Imprime o Vetor na tela
End if

End Function

select case useraction
Case "Incluir_Vetor"
'Chama a function que ira incluir um valor para o vetor
Call Incluir_Vetor
End Select
<table width="100%">
<form name="form" method="post" action="?action=Incluir_Vetor">
<td><input name="Valor_Vetor" type="text" id="Valor_Vetor"> </td>
<td><input name="tamanho" type="text" >
<input type="submit" name="Submit" value="Incluir no Vetor"></td>
'Chama a função que vizualiza todos os vetores criados

I use almost all of my sites. I hope you find it useful.

Similar Threads
Thread Thread Starter Forum Replies Last Post
multidimensional array help for a newbie grahama PHP Databases 1 May 13th, 2008 09:41 AM
Multidimensional Array macsham Beginning PHP 2 February 24th, 2005 03:30 PM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
Multidimensional array in ch9 willburke BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 November 2nd, 2004 04:44 PM
Multidimensional Array help grahama Beginning PHP 0 June 12th, 2004 09:01 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.