Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » javascript not working
javascript not working [message #923] Mon, 09 July 2007 13:13 Go to next message
interop is currently offline  interop
Messages: 45
Registered: October 2006
Member
When I try to use the Update(js) for x_person I get a "cal1 not defined" when I click on the 'select' for the start date. (this error is in the java console of my browser).

It works fine in the demo on the radicore website.

Here's the header from the html source on the radicore website

<head>
<title>Update Person (with javascript)</title>
<link rel="stylesheet" type="text/css" href="HTTP://www.radicore.org/demo/css/default.css"/>
<link rel="stylesheet" type="text/css" href="HTTP://www.radicore.org/demo/xample/style_custom.css"/>
<script language="javascript" src=" HTTP://www.radicore.org/demo/xample/javascript/usableforms.j s "/>
<script language="javascript">document.write();</script>
<script language="javascript">document.write(getCalendarStyles()); </script>
<script language="javascript" src=" HTTP://www.radicore.org/demo/xample/javascript/CalendarPopup .js "/>
<script language="javascript">document.write(getCalendarStyles()); </script>
<script language="javascript">var cal1 = new CalendarPopup(); cal1.showYearNavigation();</script>
</head>


And here's the header from my site.

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Update Person (with javascript)</title>
<link rel="stylesheet" type="text/css" href="HTTP://<removed>/css/default-wide.css" />
<link rel="stylesheet" type="text/css" href="HTTP://<removed>/xample/style_custom.css" />
<script language="javascript" src="HTTP://<removed>/xample/javascript/usableforms.js"></script >
<script language="javascript"><![CDATA[document.write();]]></script >
<script language="javascript"><![CDATA[document.write(getCalendarStyles());]] ></script>
<script language="javascript" src="HTTP://<removed>/xample/javascript/CalendarPopup.js" ></script>
<script language="javascript"><![CDATA[document.write(getCalendarStyles());]] ></script>
<script language="javascript"><![CDATA[var cal1 = new CalendarPopup(); cal1.showYearNavigation();]]></script>
</head>

I'm using radicore 1.25, php5 and mysql5. This behavior is not new with radicore 1.25- maybe there's a php.ini setting I need?

[Updated on: Mon, 09 July 2007 13:13]

Report message to a moderator

Re: javascript not working [message #924 is a reply to message #923] Mon, 09 July 2007 13:49 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
I have just tried it on my PC which runs PHP 5 and MySQL 5 without any problems.

Something on your PC is causing the javascript entries to be enclosed in '<![CDATA' and ']]>', which is why they are being ignored. The only places where createCDATASection() is used in my code is when adding the contents of header.txt or footer.txt.

You need to step through with your debugger to see what is causing this.


Re: javascript not working [message #926 is a reply to message #924] Mon, 09 July 2007 15:35 Go to previous messageGo to next message
interop is currently offline  interop
Messages: 45
Registered: October 2006
Member
ok, the xml output from include.php5 is fine. it's happening during the transformToXML(). I'm not too familiar with xsl but here's what I found.

lines 63-66 of std.head.xsl

63: <xsl:when test="@type='code'">
64: <script language="javascript">
65: <xsl:value-of select="node()"disable-output-escaping="yes"/>
66: </script>

I wrote a small test program and if I remove lines 64 and 66 the output of line 65 is not enclosed in '<![CDATA' and ']]>'

I'm running on a basic installation of rhel 4. I don't know where to go from here. Do you have any ideas?
Re: javascript not working [message #928 is a reply to message #923] Mon, 09 July 2007 16:42 Go to previous messageGo to next message
interop is currently offline  interop
Messages: 45
Registered: October 2006
Member
I guess others have run into this problem as well. See the user comments here:
http://us2.php.net/manual/en/function.xsl-xsltprocessor-tran sform-to-xml.php
Re: javascript not working [message #929 is a reply to message #926] Mon, 09 July 2007 17:35 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
The path through that code is governed by the value of the 'type' attribute in the XML file, which can either be 'file' or 'code'. This in turn is governed by the PHP code which was used to generate those XML entries. In this case the PHP code in question is found in file x_person_s02.class.inc in the _cm_setJavaScript() method, with the lines beginning
$javascript['head'][]['code'] = 'whatever';

or
$javascript['head'][]['file'] = 'whatever';

I have tried swapping the values 'code' and 'file', but I cannot reproduce the problem you describe.

This does not explain the fact that the original unaltered code works on both my home PCs and my website, but only misbehaves on your PC. This points to some sort of problem on your PC, but I am at a loss to explain what exactly.


Re: javascript not working [message #930 is a reply to message #929] Mon, 09 July 2007 17:42 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
Which web browser are you using, and are you performing the XSL transformations server-side or client-side?

Re: javascript not working [message #931 is a reply to message #930] Mon, 09 July 2007 17:51 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
Which version of PHP 5 are you using? My home PC is running 5.2.3 and I cannot reproduce the problem you describe.

Re: javascript not working [message #934 is a reply to message #931] Tue, 10 July 2007 09:00 Go to previous messageGo to next message
interop is currently offline  interop
Messages: 45
Registered: October 2006
Member
I've tried a few different browsers and php5.1.1. Here's some data:

With server-side transformations the javascript is enclosed in 'cdata' with these browsers:
Windows: IE, Mozilla Firefox
Linux: Mozilla Firefox, Konquerer

With client-side transformations:
Windows: All is fine in IE, the page will not even display in Firefox
Linux: the page will not display in Firefox, Konquerer doesn't support it

Upgrade to PHP5.2.3 and got the same results. Is your PC a Windows box? Maybe that's the difference- mine is Linux.

I'll try upgrading libxslt and libxml and let you know the results.
Re: javascript not working [message #935 is a reply to message #934] Tue, 10 July 2007 09:41 Go to previous messageGo to next message
interop is currently offline  interop
Messages: 45
Registered: October 2006
Member
An upgrade to libxslt 1.1.21 and libxml2 2.6.29 solves the problem.

With client-side transformations the page still doesn't display in Firefox on both Windows and Linux. This doesn't concern me but if you would like more information let me know.
Re: javascript not working [message #936 is a reply to message #935] Tue, 10 July 2007 10:44 Go to previous message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
I found a problem with Firefox and client-side transformations with "disable-output-escaping" a long time ago. I reported it as a bug, but the Firefox developers refuse to fix it.

Still, that doesn't matter as your upgrade of libxslt and libxml has solved your problem.



Previous Topic: refreshing
Next Topic: Update 4
Goto Forum:
  


Current Time: Sat Nov 23 19:43:40 EST 2024

Total time taken to generate the page: 0.01259 seconds