473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Concatenate dynamic variable names

I have a table that I populate with an array using ASP. As each row is
created, the form object names are appended a numeric, such as:
i = 1
<select name="select<%=i%>">
...
...
...
i = i+1
next

I then pass "i" to a javascript function, so that I can access the
values of each form object. I can't figure out how to properly
concatenate the "i" and still allow access to the value in the form
object. Currently I have:

var ps = 'platSymbol' + I;
alert(ps)
var sel = 'document.frmUpdPlatGrp.' + ps + '.value'
alert(sel)

I know I'm wrong, as this comes back as a complete string. Ultimately
I want to have something like this:

var s = document.frmUpdPlatGrp.platSymbol2.value - so that I can
actually get the value.

Can anyone help me out? Thanks in advance!

Jul 23 '05 #1
2 16519
I figured out my first question by using "eval", but now that I have
the value, I need to assign it to another dynamic form object for
holding, such as:

var ps = 'platSymbol' + I;
var sel = 'document.frmUpdPlatGrp.' + ps + '.value'
var val = eval(sel)

var ps2 = 'symbolId_changed' + I;
var hld = 'document.frmUpdPlatGrp.' + ps2 + '.value' = val

I then want to be able to access the form object like:
alert (document.formUpdPlatGrp.formObject2.value)
so that I can pass it thru my ASP page. Thanks!

Jul 23 '05 #2
On 08/07/2005 15:22, SABmore wrote:
I figured out my first question by using "eval", [...]
Sorry, but had you read the group FAQ, you'd have found that the answer
is /not/ the global eval function.
var ps = 'platSymbol' + I;
var sel = 'document.frmUpdPlatGrp.' + ps + '.value'
var val = eval(sel)

var ps2 = 'symbolId_changed' + I;
var hld = 'document.frmUpdPlatGrp.' + ps2 + '.value' = val


var elem = document.forms.frmUpdPlatGrp.elements;

elem['symbolId_changed' + I].value = elem['platSymbol' + I].value;

[snip]

Hope that helps,
Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ken Halley | last post by:
How does one refer to a variable name using a variable within a variable name??? For example, I want to perform a SQL query and use the results of the query to determine which variable to assign a...
4
by: Jas | last post by:
Hi All I guess I should just have tried this to see if it works but I don't have access to a machine running IIS and can't test it and I am itching for an answer. I want to use dynamic...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
3
by: simon | last post by:
hello, i have a form where there are multiple dropdown lists that will all be populated from the same initial data query. i have a vb class defined to make the stored proc call and that returns a...
5
by: Rolf Mander | last post by:
Hi, I need to use dynamic variable names but for objects. As you know something like that works fine: $variable="content"; $part="able"; echo ${"vari".$part}; // gives out content but i...
7
by: DavidSeck.com | last post by:
Hi guys, first post :) my question: is it possible to have dynamic variable names, I mean something like this: for($i=0;$i<x;$i++){ $y_$i = blabla; }
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.