p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Databases (http://p2p.wrox.com/forumdisplay.php?f=62)
-   -   passing Multidimensional Array Values back to form (http://p2p.wrox.com/showthread.php?t=3327)

stitch August 28th, 2003 10:06 PM

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.

mpicton September 4th, 2003 03:33 PM

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

vivis June 21st, 2013 01:59 PM

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.

All times are GMT -4. The time now is 03:32 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.