Click to See Complete Forum and Search --> : Javascript, PERL/CGI happy together??


luvdairish
11-08-2004, 11:39 PM
I'm in desperate need of help. Please reply. :confused:

I'm reading data from a input file using PERL/CGI, then displaying each line in a HTML table.

My problem is, when the page is loaded I need to hide a (PERL) variable amount of the table rows using the ID attribute. The hidden rows will be revealed when a radio button is selected. I figure I could use a Javascript loop to hide each table row by ID when the page is loaded. The condition to break out of the loop would be a PERL variable.

Questions:

1. How do I assign a PERL variable to a Javascript variable for use as the condition to break out of the Javascript loop?

2. Is there a better way of doing this? Should I use all Javascript instead?

I'm better at PERL, so any suggestions please include examples.

Jona
11-09-2004, 12:17 AM
You can hide all of the rows when the page loads, except for the one row that is the same as the Perl variable. Is that what you want?

luvdairish
11-09-2004, 01:22 AM
Hi Jona,

The PERL variable is going to be the number of lines read from the input file. Each line (or sentence) is going to be a row in the table. Below each sentence displayed on the web page will be 3 radio buttons. Based on which radio button is selected, a row will be revealed below the radio buttons with a text area for user input. I was thinking about assigning the number of lines read from the input file to a Javascript variable. This way, as I step through the Javascript loop to hide all the text area rows on page load, I have a value to increment to bring me to the next table row (text area) to hide.

For instance, as I print the HTML table tags with PERL, I will name the ID like this: <TABLE ID="table_1">

Then when I increment the for loop, I can use the value of $i to hide the next sequential ID (ID="table_2") and so on.

Your thoughts?

russell
11-09-2004, 01:35 AM
luvdairish, you are exactly on the right track. That's the way to do it. The way to assign your Perl variable to a JS variable is the same exact way you write HTML with perl. Let the Perl script generate the JavaScript.

King-Phoenix
11-09-2004, 04:49 AM
Let the Perl script generate the JavaScript.

GO ON~!

luvdairish
11-09-2004, 12:16 PM
Cool...Thanks! I just wasn't sure. I hate going in the wrong direction at first and finding out the hard way.

Good Day!