|
Convenient web based access to our favorite web design Usenet groups
|
 |
This is Interesting: Free Magazines for Graphics designers and webmasters
| Author |
| Thread |
 |
|
|
|
|
|
 |
 |
|
|
|
  12-27-05 - 08:32 AM
|
Hi, ya'll:
I've got a situation I can't fathom.
I have a simple js function:
var region = new Array();
var region = new Array();
region["11"]="the upper-outer quadrant";
region["13"]="the upper-inner quadrant";
.
function decodeRegion(score,target1) {
if (score > 100) {score -= 100;}
mV = score.toString(10);
document.getElementById(target1).innerHTML = region[mV];
}
In a plain vanilla HTML page, I call the above with either an
onLoad="decodeRegion(11,'insert_here') or with a checkbox using the same
syntax, but with an onClick event, e.g., as follows:
<input type=checkbox onClick="decodeRegion(11,'insert_here');">ClickMe
<span id="insert_here"></span>.
Either the onLoad or onClick events work fine; however, when I create then
HTML page wirth Perl, upon calling exactly the same function (cut and
paste and adding appropriate escapes ''), I get an error. Using Opera,
the js console error displayed is:
ReferenceError message: Statement on line 1: Reference to undefined
variable: decodeRegion.
In IE, I get 'object expected' error.
What is happening, and what can I do to resolve the issue?
TIA,
--
Ed Jay (remove M to respond by email)
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
 |
Re: Perl/Javascript problem |
 |
|
 |
|
|
|
  12-27-05 - 08:32 AM
|
Jump to follow up, below...
Ed Jay <edMbj@aes-intl.com> wrote:
>Hi, ya'll:
>
>I've got a situation I can't fathom.
>
>I have a simple js function:
>
>var region = new Array();
> var region = new Array();
> region["11"]="the upper-outer quadrant";
> region["13"]="the upper-inner quadrant";
> ..
>
>function decodeRegion(score,target1) {
> if (score > 100) {score -= 100;}
> mV = score.toString(10);
> document.getElementById(target1).innerHTML = region[mV];
>}
>
>In a plain vanilla HTML page, I call the above with either an
>onLoad="decodeRegion(11,'insert_here') or with a checkbox using the same
>syntax, but with an onClick event, e.g., as follows:
>
><input type=checkbox onClick="decodeRegion(11,'insert_here');">ClickMe
><span id="insert_here"></span>.
>
>Either the onLoad or onClick events work fine; however, when I create then
>HTML page wirth Perl, upon calling exactly the same function (cut and
>paste and adding appropriate escapes ''), I get an error. Using Opera,
>the js console error displayed is:
>
>ReferenceError message: Statement on line 1: Reference to undefined
>variable: decodeRegion.
>
>In IE, I get 'object expected' error.
>
>What is happening, and what can I do to resolve the issue?
>
Follow up:
I should have mentioned that I'm using a linked external javascript file.
I also just discovered if I put the function and array on the HTML page
generated by my Perl script, it works. WT...?
--
Ed Jay (remove M to respond by email)
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
 |
Re: Perl/Javascript problem |
 |
|
 |
|
|
|
  12-27-05 - 08:32 AM
|
Ed Jay <edMbj@aes-intl.com> wrote:
> Either the onLoad or onClick events work fine; however, when I create
> then HTML page wirth Perl, upon calling exactly the same function (cut
> and paste and adding appropriate escapes ''),
Does your Perl script use:
use strict;
use warnings;
if not, add them.
Also, if you output several lines of something, use:
print <<'EOT';
.....
.....
.....
.....
EOT
with single qoutes around EOT you don't have to escape a thing.
If you want string interpolation to work, use "" around EOT, e.g.
my $msg = 'hello, world!';
print <<"EOT";
....
....
$msg
....
EOT
Make sure there is *nothing* after the ending EOT (which is just a random
name, you can probably think up a better end of text marker), just a
return.
Common mistakes: - white space other then end of line after EOT
- a ; after EOT
(the ending one I mean).
--
John Perl SEO tools: http://johnbokma.com/perl/
or have them custom made
Experienced (web) developer: http://castleamber.com/
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
 |
Re: Perl/Javascript problem |
 |
|
 |
|
|
|
  12-27-05 - 08:33 AM
|
John Bokma <john@castleamber.com> wrote:
>Ed Jay <edMbj@aes-intl.com> wrote:
>
>
>Does your Perl script use:
>
>use strict;
>use warnings;
Yes.
>
>if not, add them.
>
>Also, if you output several lines of something, use:
I'm not. Short lines.
>
>print <<'EOT';
>.....
>.....
>.....
>.....
>EOT
>
>with single qoutes around EOT you don't have to escape a thing.
>
>If you want string interpolation to work, use "" around EOT, e.g.
>
>my $msg = 'hello, world!';
>
>print <<"EOT";
>....
>....
>$msg
>....
>EOT
>
>
>Make sure there is *nothing* after the ending EOT (which is just a random
>name, you can probably think up a better end of text marker), just a
>return.
>
>Common mistakes: - white space other then end of line after EOT
> - a ; after EOT
>
>(the ending one I mean).
Everything looks fine, codewise. Using exactly the same syntax, but
including the js and array on the generated page works fine. It's only
when I link to an external js file do I run into the problem. So...I now
have the js on the created page.
Thanks.
--
Ed Jay (remove M to respond by email)
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
|
|
 |
 |
Re: Perl/Javascript problem |
 |
|
 |
|
|
|
  12-28-05 - 12:03 AM
|
Ed Jay wrote:
> Hi, ya'll:
>
> I've got a situation I can't fathom.
>
> I have a simple js function:
>
> var region = new Array();
> var region = new Array();
> region["11"]="the upper-outer quadrant";
> region["13"]="the upper-inner quadrant";
> ..
>
> function decodeRegion(score,target1) {
> if (score > 100) {score -= 100;}
> mV = score.toString(10);
> document.getElementById(target1).innerHTML = region[mV];
> }
>
> In a plain vanilla HTML page, I call the above with either an
> onLoad="decodeRegion(11,'insert_here') or with a checkbox using the same
> syntax, but with an onClick event, e.g., as follows:
>
> <input type=checkbox onClick="decodeRegion(11,'insert_here');">ClickMe
> <span id="insert_here"></span>.
>
> Either the onLoad or onClick events work fine; however, when I create then
> HTML page wirth Perl, upon calling exactly the same function (cut and
> paste and adding appropriate escapes ''), I get an error. Using Opera,
> the js console error displayed is:
>
> ReferenceError message: Statement on line 1: Reference to undefined
> variable: decodeRegion.
>
> In IE, I get 'object expected' error.
>
> What is happening, and what can I do to resolve the issue?
>
> TIA,
>
What happens if you compare the HTML source between the two pages?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
|
|
 |
| All times are GMT. The time now is 02:14 PM. |
 |
|
|
|
|
|  |
|