Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.

var headname1= "@head1"; var headname2= "@head2";
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 headname=[]; for(var i=0;i<total_columns;i++) { headname[i+1]= "@line_arry[(i)]"; }
This code doesnot work. It displays only the first column. i.e.
headname[1] = "Order"; headname[2] = "Order";
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[i+1]= "@line_arry[(0)]"; headname[i+1]= "@line_arry[(1)]"; "@line_arry[i]" doesnt work whereas "@line_arry[0], @line_arry[1] works.
Can anyone suggeest why it is not performing looping action using variable i

In reply to Loop function in Javascript fails when combined with perl array by ash1351

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-05-30 06:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found