Web Design Web Design Forum
Registration is free! Here you can view your subscribed threads, work with private messages and edit your profile and preferences Calendar Find other members Frequently Asked Questions Search
Home Web Design

Convenient web based access to our favorite web design Usenet groups

web design reviews

This is Interesting: Free Magazines for Graphics designers and webmasters  





  Last Thread  Next Thread
Author
Thread Post New Thread   

Perl/Javascript problem
 

Ed Jay




quote this post edit post

IP Loged report this post

Old Post  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
 

Ed Jay




quote this post edit post

IP Loged report this post

Old Post  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
 

John Bokma




quote this post edit post

IP Loged report this post

Old Post  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
 

Ed Jay




quote this post edit post

IP Loged report this post

Old Post  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
 

John Bokma




quote this post edit post

IP Loged report this post

Old Post  12-27-05 - 11:28 AM  
Ed Jay <edMbj@aes-intl.com> wrote:

> 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.

Odd, odd. I thought that somehow you got Perl to interpolate something
that it shouldn't.

--
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
 

Jerry Stuckle




quote this post edit post

IP Loged report this post

Old Post  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 ]
Re: Perl/Javascript problem
 

Ed Jay




quote this post edit post

IP Loged report this post

Old Post  12-28-05 - 12:03 AM  
Jerry Stuckle <jstucklex@attglobal.net> wrote:

>Ed Jay wrote: 
>
>What happens if you compare the HTML source between the two pages?

The HTML page that works is different than the one generated by Perl. I'll
try it today. Thanks for the idea.

--
Ed Jay (remove M to respond by email)


Post Follow-Up to this message ]
Re: Perl/Javascript problem
 

Ed Jay




quote this post edit post

IP Loged report this post

Old Post  12-28-05 - 12:04 AM  
John Bokma <john@castleamber.com> wrote:

>Ed Jay <edMbj@aes-intl.com> wrote:
> 
>
>Odd, odd. I thought that somehow you got Perl to interpolate something
>that it shouldn't.

Problem solved. There was another script in the linked file that was
problematic. Had nothing to do with what I was trying to do, but it killed
all subsequent function calls. My app comprises several Perl-generated
HTML pages. The errant function is used on an early page and it's error
wasn't noted.

Thanks for your help.

--
Ed Jay (remove M to respond by email)


Post Follow-Up to this message ]
Sponsored Links
 





All times are GMT. The time now is 02:14 PM. Post New Thread   
  Previous Last Thread   Next Thread next
Webmaster forum archive | Show Printable Version | Email this Page | Subscribe to this Thread

Popular forums

Adobe Photoshop forum Macromedia Flash Web Site Design
Dreamweaver FrontPage forum
JavaScript Forum XML forum
Style Sheets VRML
Forum Jump:
Rate This Thread:

 

XML RSS Feed web design latest articles Syndicate our forum via XML or simple JavaScript

Web Design archive  Database administration help  


Top Home  -  Register  -  Control Panel   -  Memberlist  -  Calendar  -  Faq  -  Search Top