Solved

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

Posted on 2003-10-30
3
135 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
Comment Utility
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
Comment Utility
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
Comment Utility
+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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
remove Handler and Add Handler for one file 3 31
XSLT 5 36
Disabling automatic web page translations 9 31
ColdFusion Rereplace 3 61
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

763 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

7 Experts available now in Live!

Get 1:1 Help Now