feeding a value to a js file from a perl one

N

Nikos

Previsouly i had the following script inside my index.pl

<script type='text/javascript'>

var textToShow = "$data";
var tm;
var pos = 0;
var counter = 0;

function init()
{ tm = setInterval("type()", 45) }

function type()
{
if (textToShow.length != pos)
{
d = document.getElementById("DivText");
c = textToShow.charAt(pos++);

if (c.charCodeAt(0) != 10)
d.appendChild(document.createTextNode(c));
else
d.appendChild(document.createElement("br"));

counter++;

if (counter >= 1800 && (c.charCodeAt(0) == 10 || c == "."))
{
d.appendChild(document.createElement("br"));
d.appendChild(document.createTextNode("Press any key..."));
counter = 0;
clearInterval(tm);
document.body.onkeypress = function () {
document.getElementById("DivText").innerHTML = '';
tm =
setInterval("type()", 50);

document.body.onkeypress = null; };
}
}
else
clearInterval(tm);
}
</script>

<body onload=init()>
<center>
<div id="DivText" align="Left" style="
background-image: url(../data/images/kenzo.jpg);
border: Ridge Orange 5px;
width: 850px;
height: 500px;
color: LightSkyBlue;
font-family: Times;
font-size: 18px;">
</div

but with the idea of seperating code i wanted to put the js file out of
the perl but still remian functional:


$data =~ s/\n/\\n/g;
$data =~ s/"/\\"/g;
$data =~ tr/\cM//d;

#*******************************************************************************
<script type="text/javascript" src="../script.js"></script>
#*******************************************************************************

print br(), br(), br();


I just want to give the variable $data to the javascript file and then
javascript do calculations with it.
 
M

Mark Clements

Nikos said:
Previsouly i had the following script inside my index.pl

<script type='text/javascript'>

var textToShow = "$data";
var tm;
var pos = 0;
var counter = 0;
I just want to give the variable $data to the javascript file and then
javascript do calculations with it.
There are many answers to this particular problem: one of them is
HTML::Template.

However: at this point, Nikos, I am going to have to give up trying to
help you. This is a forum for specific questions: you are using it as
your main learning tool, though you choose to ignore most of the advice.
You need to learn about CGI programming, and in fact programming in
general. There are many howtos and faqs available on the web and a host
of reference material. Google is your friend.

I wish you good luck.

Mark
 
N

Nikos

Mark said:
However: at this point, Nikos, I am going to have to give up trying to
help you. This is a forum for specific questions: you are using it as
your main learning tool, though you choose to ignore most of the advice.
You need to learn about CGI programming, and in fact programming in
general. There are many howtos and faqs available on the web and a host
of reference material. Google is your friend.

I wish you good luck.

Mark

Thanks Mark but i think i will give up on programming too.
I like Perl and i know some basic stuff but actually i cant put much
effort on reading.
I liek things to be be pretty much self-explanatory.
Anyway thank you for tryign to help me and sorry for the annoyance i caused.
 
M

Mark Clements

Nikos said:
Thanks Mark but i think i will give up on programming too.
You shouldn't be too disheartened: you have been trying to run before
you could walk, although you don't seem to have realised this. Start
with the basics and build up.
I like Perl and i know some basic stuff but actually i cant put much
effort on reading.
This is unfortunate: reading is the key to education, in pretty much any
discipline.
I liek things to be be pretty much self-explanatory.
Programming isn't easy: you shouldn't expect everything to magically
fall into place without understanding the whys and wherefores. If it
were easy, then it wouldn't attract people who like to be challenged,
and who like making difficult things work, and just as importantly, it
wouldn't pay. New languages only become self-explanatory (up to a point)
when you are already familiar with a variety of languages. This takes time.
Anyway thank you for tryign to help me and sorry for the annoyance i
caused.
The annoyance (despair?) was caused by you expecting too much from the
readers of this newsgroup, and moreover by you refusing to listen to
them. Being a beginner is not a problem (it can take years to reach
proficiency): being a beginner who doesn't want to listen *is*.

anyway, best of luck,

Mark
 
B

burlo.stumproot

Mark Clements said:
You shouldn't be too disheartened: you have been trying to run before
you could walk, although you don't seem to have realised this. Start
with the basics and build up.

This is unfortunate: reading is the key to education, in pretty much
any discipline.

Programming isn't easy: you shouldn't expect everything to magically
fall into place without understanding the whys and wherefores. If it
were easy, then it wouldn't attract people who like to be challenged,
and who like making difficult things work, and just as importantly, it
wouldn't pay. New languages only become self-explanatory (up to a
point) when you are already familiar with a variety of languages. This
takes time.

The annoyance (despair?) was caused by you expecting too much from the
readers of this newsgroup, and moreover by you refusing to listen to
them. Being a beginner is not a problem (it can take years to reach
proficiency): being a beginner who doesn't want to listen *is*.

anyway, best of luck,

Mark

Very well said Mark.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top