ash1351 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I am taking backend perl variables and using it at the front end for display. Here is the code. head1 and head2 are the header names taken from perl script. I use that and display those headers of grid on webpage.
Now, if there are 100 headers, i would have to assign variables 100 times separately. so its better to make it dynamic. Taking values from backend and assigning it to javascript variable. This task will be dynamic. Here is my attempted code for that. I hav taken all the headers from backend and assigned it to line_array. @line_arry is the name of that array. If i do @line_arry[0] and so on. appropriate values will be displyaed.var headname1= "@head1"; var headname2= "@head2";
This code doesnot work. It displays only the first column. i.e.var headname=[]; for(var i=0;i<total_columns;i++) { headname[i+1]= "@line_arry[(i)]"; }
Order is the name of the first header. In headname2, header of second column should be displayed. but it still displays "Order" If i write the below code, it displays first and second header.headname[1] = "Order"; headname[2] = "Order";
Can anyone suggeest why it is not performing looping action using variable iheadname[i+1]= "@line_arry[(0)]"; headname[i+1]= "@line_arry[(1)]"; "@line_arry[i]" doesnt work whereas "@line_arry[0], @line_arry[1] works.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Loop function in Javascript fails when combined with perl array
by jeffa (Bishop) on Aug 26, 2015 at 22:50 UTC | |
by Anonymous Monk on Aug 26, 2015 at 23:50 UTC | |
|
Re: Loop function in Javascript fails when combined with perl array
by philipbailey (Curate) on Aug 26, 2015 at 22:20 UTC | |
|
Re: Loop function in Javascript fails when combined with perl array
by 1nickt (Canon) on Aug 26, 2015 at 22:12 UTC |