Solved

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

Posted on 2003-10-30
3
139 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

726 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