Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Calling an included javascript fileCalling an included javascript file
Previous
 
Next
New Post
11/9/2010 4:07 AM
 
I'm hoping someone can help with a problem using an included Javascript file.

The page has a HTML module on it that contains mostly HTML, a link to an included js file '/js/pregnant.js' and a bit of javascript in the html to validate the dates.

It all works fine on the old site in DNN 4.05.01 and you can see it working just fine at http://www.sufw.com.au/Information/PregnancyCalendar/tabid/170/Default.aspx

But on the new site in DNN 5.05.01 it keeps coming up with a javascript error  - 'Null' is null or not an object on a couple of lines. Everything is the same as best I can tell between the sites, and I managed to get Telerik editor to not strip out the <script> tags. The new dev site is at http://www.sufw.31.websecurestores.com/Information/PregnancyCalender.aspx where you can see the javascript errors and that the form will not draw the text input boxes on the top of the form.

Is there some difference in DNN 5.0 that stops is from rendering a Javascript form the same way as DNN 4? I suspect this may have something to do with DNN renaming the form objects, but don't know how to check that (just red some forums on it).  The include file is loading OK, because if I put an elert in it, it comes up fine.

Any help would be greatly appreciated.

Cheers Greg
 
New Post
11/9/2010 12:33 PM
 
theres no difference how javascript works in 5.x from 4.x. There are additional scripts included for ms ajax and jquery, which in theory could clash. When i view your site in firefox the error states "chooseDay is null" on Line 694 - and looking at the DOM I can't see that field, so your error may not be javascript related, please check your code for where the chooseDay field is generated.

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
11/9/2010 4:56 PM
 
Hi Cathal,
Thanks for having a look at that. You right about the missing fields, when the script is working fine (on the DNN 4 site) it draws three input boxes at the top of the form were you enter the month, day and year. When I view the form in the editor design mode you can see two of the fields being rendered, but when I hit save and look at the form those fields aren't there.  The editor in DNN4 behaves the same way excpet than when you view the page it draws the three boxes.

So it looks like DNN 5 is having trouble drawing the three fields and thus the javascript error about not being able to find them. I'm not a javascript gun, but it looks like the included JS file is supposed to draw the fields and do the calculations. 

Below is the content of the HTML box on the page, and the included JS file can be viewed at http://www.sufw.31.websecurestores.co...
You'll notice that the JS script is included from the HTML text, but I've also tried to put it in the Page header and that makes no difference.

Once again thanks fo having a look at this.

Cheers Greg

<!-- CONTENT BEGIN .. -->   <!--
Pregnancy Dates Calculator
February 28, 1999

This calculator was created by Charles Hu for the Medical College of
Wisconsin General Internal Medicine Clinic.  This calculator may not be
copied without the consent from the author.  chuckhu@hotmail.com--> <script language="JavaScript" src="/js/pregnant.js"></script>  <center>
<table cellspacing="0" cellpadding="3" border="0" bgcolor="#eeeeee">
    <form method="post" name="DueDate">
        <input type="hidden" name="theDate" />
        <tbody>
            <tr bgcolor="#e3e9f8">
                <td align="center" colspan="2"><strong>  Last menstrual period : </strong>    <script language="JavaScript">
<!--

var today = new Date();

var mm = today.getMonth();
var dd = today.getDate();
var yy = today.getYear();

//  The '0' indicates this does NOT come from EDD Form
dateSelect(mm,dd,yy,0);

// -->
</script></td>
            </tr>
            <tr bgcolor="#e3e9f8">
                <td align="center" colspan="2"><input type="button" onclick="dueDate(this.form)" value="Calculate Forward" name="button" />   &nbsp;&nbsp;   <input type="button" onclick="resetForm()" value="Reset This Form" name="button" /></td>
            </tr>
            <tr>
                <td align="right">Conception Occurred : <br />
                <!--chuckhu conceived-->  <font size="-1"><em>  (about two weeks after last menstrual period)  </em></font></td>
                <td valign="middle" align="left">  <!--input type=text value="" size="30" maxlength="30" name="concep"--></td>
            </tr>
            <tr>
                <td align="right">First Trimester Ends  <font size="-1"><em>  (12 weeks)  </em></font>:</td>
                <td valign="top" align="left">  <!--input type=text value="" size="30" maxlength="30" name="first"--></td>
            </tr>
            <tr>
                <td align="right">Second Trimester Ends  <font size="-1"><em>  (27 weeks)  </em></font>:</td>
                <td valign="top" align="left">  <!--input type=text value="" size="30" maxlength="30" name="second"--></td>
            </tr>
        </tbody>
        <form method="post" name="eddForm">
            <input type="hidden" name="theDate" />
            <tr bgcolor="#e3e9f8">
                <td align="right"><strong>  Estimated Due Date</strong>   <font size="-1"><em>  (40 weeks)  </em></font>:</td>
                <td> <script language="JavaScript">
<!--

var today = new Date();

var mm = today.getMonth();
var dd = today.getDate();
var yy = today.getYear() + 1;

//  The last '1' indicates this comes from the EDD form
dateSelect(mm,dd,yy,1);

// -->
</script></td>
            </tr>
            <tr bgcolor="#e3e9f8">
                <td align="center" colspan="2"><input type="button" onclick="getLMP(this.form)" value="Calculate Backward" name="button" /></td>
            </tr>
        </form>
    </form>
</table>
<form method="post" name="weeksPreg">
    <input type="hidden" value="0" name="calcYet" /> <input type="hidden" name="theDate" />
    <table cellspacing="0" cellpadding="5" border="0" bgcolor="#ccccff">
        <tbody>
            <tr>
                <td align="center">On   <script language="JavaScript">
<!--

var today = new Date();

var mm = today.getMonth();
var dd = today.getDate();
var yy = today.getYear();

//  The last '2' indicates this comes from EGA form
dateSelect(mm,dd,yy,2);

// -->
</script>,   you will be   <input type="text" name="weeks" size="6" />   weeks pregnant.</td>
            </tr>
            <tr>
                <td align="center"><input type="button" onclick="datetoWeeks(this.form)" value="Calculate Date --&gt; Weeks" name="button" />   &nbsp; &nbsp;   <input type="button" onclick="weekstoDate(this.form)" value="Calculate Weeks --&gt; Date" name="button" /></td>
            </tr>
        </tbody>
    </table>
</form>
</center> <!-- .. CONTENT END -->

 
New Post
11/10/2010 4:18 AM
 
as the scripts over 11 years old, i'm more surprised it works in dnn4.x rather than that it doesn't work in dnn5.x.
 
The script also contains dubious logic e.g. it identifies if a browser is IE4 or greater, or netscape navigator 6 or greater - obviously these are ancient browsers (and theres no equivalent checks for firefox/opera as they didn't exist in those days) - however the logic is relatively simple so its likely it still works.

I'd suggest the error is actually caused by the tags that are stripped out of the pasted javacript/html by the different editors (4.x used FCK, 5.2.0+ use telerik). As such I'd consider creating a custom module (or custom skin) that the necessary html/script is in and using that. Alternatively switch the editor to "basic text box" and save that. Finally, you might consider swapping the editor back to the FCK version - http://www.dotnetnuke.com/Resources/W...

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Calling an included javascript fileCalling an included javascript file


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out