Hi Narendra,
I'm wondering why you use toString() method here?
I think 'value_at_' + i
would also work fine
On Jun 9, 10:09 pm, Narendra sisodiya
wrote:
> try to use object like this:
>
> var myObject={};
> var count=10;
>
> for(var i=0;i {
> myObject['value_at_'+i.toString()]="value at "+
thanks mark, I knew there was a way as its similar to flash as
coding , just I was putting the sqr brackets in wrong place
thanks again
On Jun 9, 9:35 am, simon wrote:
> $.myvariable1
> $.myvariable3
> $.myvariable2
> now I would like to add the number part of the variable to it
> dynamically.
var i=1;
$['myvariable'+i] === $.myvariable1
See: http://www.javascripttoolbox.com/bestpractices/#squarebracket
Matt Kruse
what i havev done is constructe my page and all things working etc etc
but long winded, then what I do is then begin to reduce the code down
that is on that page whether it be asp, php of js, this way I learn
more about the script and in future do that method instead and then my
coding gets reduce
what type of updating are you gonna do ? you mean to post these variables ?
On Tue, Jun 9, 2009 at 5:43 PM, simon wrote:
>
> thanks for all the options guys, I did think of arrays but I got a lot
> of updating to do if so and just to see if that could be done.
>
> luckly I only have three variab
thanks for all the options guys, I did think of arrays but I got a lot
of updating to do if so and just to see if that could be done.
luckly I only have three variables so not too much of an issue.
I also was going to use asp scripting but again if others take on my
work here it gets more visuall
yeah agree . Its depend on the requirement if some one want to manipulate
variable with random number than object is useful otherwise array is good
option.
~N a R e N
On Tue, Jun 9, 2009 at 8:46 PM, waseem sabjee wrote:
> yeah. so its either an array or object.
>
>
> but if you really wanna
try to use object like this:
var myObject={};
var count=10;
for(var i=0;iwrote:
> sorry i had a syntax error
>
> heres the code
> see just declare an array
> declare the maximum number you want
>
> then loop through them one by one asigning a number to each one :)
>
>
> var myVar = new Array();
yeah. so its either an array or object.
but if you really wanna get messy and have variables like you listed
you could echo it out through php script or do an asp response.write
however that uses up server side memory to generate JavaScript on run time.
so i woul say Array or Object :)
On Tue
sorry i had a syntax error
heres the code
see just declare an array
declare the maximum number you want
then loop through them one by one asigning a number to each one :)
var myVar = new Array(); // declare array
var myvarcount = 10; // maximum vars
for(var i = 0; i < myvarcount; i++) { // si
Why not use an array ?
var myVar = new Array();
var myvarcount = 10;
for(int i = 0; i < myvarcount; i++) {
myVar[i] = "I am number : " + i;
}
On Tue, Jun 9, 2009 at 4:35 PM, simon wrote:
>
> I have some simple variables
>
> $.myvariable1
> $.myvariable3
> $.myvariable2
>
>
> now I would like
11 matches
Mail list logo