Solved

Simple question : How can I replace array variable names to my database field names?

Posted on 2003-10-30
3
136 Views
Last Modified: 2010-04-06
I am using 1 radio button to get 3 values by splitting the values so I get the Product name, reference and the amount, like the code below:

<% Dim arrProduct
   arrProduct = Split (Request.Form ("radio1") , ",") %>
                                          Product amount : <%= arrProduct (0) %> <br>
Product item : <%= arrProduct (1) %> <br>
Reference : <%= arrProduct (2) %>

How can I replace the variable names to match my database fields?
The array corresponding to the database field is as follows:

<%= arrProduct (0) to amount
<%= arrProduct (1) to item
<%= arrProduct (2) to reference

My SQL statement is:

SQLstr      = "INSERT INTO epayment(amount, item, reference, name, designation, regNo, email, company, address, telephone, Date, fax) VALUES('" & _
0
Comment
Question by:zamorin
  • 2
3 Comments
 
LVL 3

Expert Comment

by:DelTreme
ID: 9656761
Try something like this:

Dim arrRecName(100)
Dim arrRecValue(100)

For i = 0 to recSet.Field.Count - 1
  arrRecName(i) = recSet.Fields(i).Name
  arrRecValue(i) = recSet(i)

  %><%=arrRecName(i)%> = <%=arrRecValue(i)%><br><%

Next

0
 
LVL 3

Expert Comment

by:DelTreme
ID: 9656777
If that doesn't satisfy you: There's no way to convert items from a database to a variable name.
0
 
LVL 15

Accepted Solution

by:
VincentPuglia earned 30 total points
ID: 9657964
+Hi Zamorin,

I'm not certain what you mean, nor am I an asper, but if your Split creates an array (3 times longer than number of records)  and you wish to place that array within a javascript array, the following should work:

<SCRIPT TYPE="text/javascript">
<!--
var arrProduct = new Array();
var items = references = products = new Array();
var arrProduct = <% =Split(Request.Form("radio1"),",") %>
for ( var i = 0; i < arrProduct.length; i++)
   items[i] = arrProduct[i++];
  references[i] = arrProduct[i++];
  products[i] = arrProducts[i++];
// -->
</SCRIPT>

Vinny
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
create wsdl for check policy price 32 31
remove Handler and Add Handler for one file 3 39
selectSingleNode in Access 2013 11 53
API Soap Calls 4 87
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to count occurrences of each item in an array.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now