javascript problem (sorry for the length of post)

They have: 14 posts

Joined: Dec 2001

Hi,
I've got a problem with some javascript. It's giving me an error, but I cannot work out why it is giving it to me. I've attached the file as an HTML file, but it's actually generated by some ASP. I don't think that makes any difference, because the error is the same even if it's run directly.

Many thanks
Andy

<--CODE STARTS HERE-->

<script language="JavaScript">

</script>

Level Three Virtual Control Panel

A.bodylink:link {text-decoration: none; font: 12px Arial,Helvetica; font-weight: bold; color: #2A1652;}
A.bodylink:visited {text-decoration: none; font: 12px Arial,Helvetica; font-weight: bold; color: #2A1652;}
A.bodylink:active {text-decoration: none; font: 12px Arial,Helvetica; font-weight: bold; color: #2A1652;}
A.bodylink:hover {text-decoration: none; font: 12px Arial,Helvetica; font-weight: bold; color: #9AC819;}
.bodycopy {font: 12px Arial,Helvetica; color: #444444;}
.small {font: 11px Arial,Helvetica; color: #444444;}
.smallbold {font: 11px Arial,Helvetica; font-weight: bold; color: #444444;}
.bold {font: 12px Arial,Helvetica; font-weight: bold; color: #444444;}
.white {font: 12px Arial,Helvetica; font-weight: bold; color: #ffffff;}
.headline {font: 20px Arial,Helvetica; font-weight: bold; color: #2A1652;}
.subheadline {font: 12px Arial,Helvetica; font-weight: bold; color: #2A1652;}
.headline2 {font: 20px Arial,Helvetica; font-weight: bold; color: #9AC819;}

Level Three Virtual Control Panel

 

<script language="javascript">
var formdirty;
formdirty==false;
</script>

Publications - Add/Edit Article

Add/Edit Article Information

Use the form below to add or edit article information:

  Indicates a required field

Field Descrition
Your Input Here

Current status

DEFAULT

Web Abstract Article

Archive Article

Bilingual Available

Headline

Headline (English)

Summary

Mae yna fwy i arwain côr na chwifio breichiau ...

Summary (English)
HTML Editor

Sub-section

None Selected

Author
 

Pages

(to add / remove pages, please usethe links at the bottom of the page)

Expiry date for web version

Select a date

Live date for archive version

Select a date

Audio Available

 

 
Click here to upload an audio clip.

Complete archive text
HTML Editor


Wrth i arweinydd un o gorau meibion mwya’ adnabyddus Cymru farw dros wyliau’r Nadolig, fe gafodd un arall MBE yn rhestr anrhydeddau’r flwyddyn newydd.
Roedd y diweddar Glynne Jones, a fu farw yn 72 mlwydd oed, yn arwain Côr Meibion Pendyrus ers bron i 40 mlynedd. Mae Alwyn Humphreys MBE newydd ddathlu 21 mlynedd fel Cyfarwyddwr Cerdd Côr Orffiws Treforys.

Complete archive text (English)
HTML Editor


Wrth i arweinydd un o gorau meibion mwya’ adnabyddus Cymru farw dros wyliau’r Nadolig, fe gafodd un arall MBE yn rhestr anrhydeddau’r flwyddyn newydd.

Pages in this article: 1

1

Rearrange pages

Delete this article

Navigation

Level Three Virtual Control Panel (c) 2001 Level Three

Telephone Support: 0870 750 2355   Email Support: [email protected]

<script language="javascript">
function confirmdelete()
// Confirm deletion
{
if (confirm("Are you sure you want to delete this article ?")==false)
{
return(false);
}
else
{
document.deletearticle.submit()
return (true);
}
}

function click_audioavailable()
// Enabled / disable audiofile field
{
if (doarticleedit.audioavailable.checked==true)
{
with (document.all)
{
ID_audiofile.style.visibility="visible";
ID_audiofilelink.style.visibility="visible";
}
}
else
{
with (document.all)
{
ID_audiofile.style.visibility="hidden";
ID_audiofilelink.style.visibility="hidden";
}
}
return (true);
}

function click_displayselections()
// options are;
// Weekly Web
// Archived
// Bilingual
// This controls;
// Headline, summary, ExpiryDate for Web Edition, liveDate for Archive Edition, Archive Text, pages
// We then may show or not english versions of headline, summary and archive text if bilingual = true
{
if (doarticleedit.bilingualavailable.checked==true)
{
if (doarticleedit.weeklywebedition.checked==true)
{
if (doarticleedit.archived.checked==true)
{
with (document.all)
{
ID_PagesInArticle.style.visibility="visible";
ID_PagesInArticle.style.display="block";
ID_pages.style.visibility="visible";
ID_pages.style.display="block";
ID_expirydateforwebedition.style.visibility="visible";
ID_expirydateforwebedition.style.display="block";
ID_livedateforarchiveversion.style.visibility="visible";
ID_livedateforarchiveversion.style.display="block";
ID_completearchivetext.style.visibility="visible";
ID_completearchivetext.style.display="block";
ID_completearchivetextenglish.style.visibility="visible";
ID_completearchivetextenglish.style.display="block";
ID_englishheadline.style.visibility="visible";
ID_englishheadline.style.display="block";
ID_englishsummary.style.visibility="visible";
ID_englishsummary.style.display="block";
return (true);
}
}
else
{
with (document.all)
{
ID_PagesInArticle.style.visibility="visible";
ID_PagesInArticle.style.display="block";
ID_expirydateforwebedition.style.visibility="visible";
ID_expirydateforwebedition.style.display="block";
ID_pages.style.visibility="visible";
ID_pages.style.display="block";
ID_livedateforarchiveversion.style.visibility="visible";
ID_livedateforarchiveversion.style.display="block";
ID_completearchivetext.style.visibility="hidden";
ID_completearchivetext.style.display="none";
ID_completearchivetextenglish.style.visibility="hidden";
ID_completearchivetextenglish.style.display="none";
ID_englishheadline.style.visibility="visible";
ID_englishheadline.style.display="block";
ID_englishsummary.style.visibility="visible";
ID_englishsummary.style.display="block";
return (true);
}
}
else
{
if (doarticleedit.archived.checked==true)
{
with (document.all)
{
ID_PagesInArticle.style.visibility="hidden";
ID_PagesInArticle.style.display="none";
ID_pages.style.visibility="hidden";
ID_pages.style.display="none";
ID_expirydateforwebedition.style.visibility="hidden";
ID_expirydateforwebedition.style.display="none";
ID_livedateforarchiveversion.style.visibility="visible";
ID_livedateforarchiveversion.style.display="block";
ID_completearchivetext.style.visibility="visible";
ID_completearchivetext.style.display="block";
ID_completearchivetextenglish.style.visibility="visible";
ID_completearchivetextenglish.style.display="block";
ID_englishheadline.style.visibility="hidden";
ID_englishheadline.style.display="none";
ID_englishsummary.style.visibility="hidden";
ID_englishsummary.style.display="none";
return (true);
}
}
else
{
with (document.all)
{
ID_PagesInArticle.style.visibility="hidden";
ID_PagesInArticle.style.display="none";
ID_expirydateforwebedition.style.visibility="hidden"
ID_expirydateforwebedition.style.display="none";
ID_pages.style.visibility="hidden";
ID_pages.style.display="none";
ID_livedateforarchiveversion.style.visibility="hidden";
ID_livedateforarchiveversion.style.display="none";
ID_completearchivetext.style.visibility="hidden";
ID_completearchivetext.style.display="none";
ID_completearchivetextenglish.style.visibility="hidden";
ID_completearchivetextenglish.style.display="none";
ID_englishheadline.style.visibility="hidden";
ID_englishheadline.style.display="none";
ID_englishsummary.style.visibility="hidden";
ID_englishsummary.style.display="none";
return (true);
}
}
}
}
else
{
if (doarticleedit.weeklywebedition.checked==true)
{
if (doarticleedit.archived.checked==true)
{
with (document.all)
{
ID_PagesInArticle.style.visibility="visible";
ID_PagesInArticle.style.display="block";
ID_pages.style.visibility="visible";
ID_pages.style.display="block";
ID_expirydateforwebedition.style.visibility="visible";
ID_expirydateforwebedition.style.display="block";
ID_livedateforarchiveversion.style.visibility="visible";
ID_livedateforarchiveversion.style.display="block";
ID_completearchivetext.style.visibility="visible";
ID_completearchivetext.style.display="block";
ID_completearchivetextenglish.style.visibility="visible";
ID_completearchivetextenglish.style.display="block";
ID_englishheadline.style.visibility="hidden";
ID_englishheadline.style.display="none";
ID_englishsummary.style.visibility="hidden";
ID_englishsummary.style.display="none";
return (true);
}
}
else
{
with (document.all)
{
ID_PagesInArticle.style.visibility="visible";
ID_PagesInArticle.style.display="block";
ID_expirydateforwebedition.style.visibility="visible";
ID_expirydateforwebedition.style.display="block";
ID_pages.style.visibility="visible";
ID_pages.style.display="block";
ID_livedateforarchiveversion.style.visibility="visible";
ID_livedateforarchiveversion.style.display="block";
ID_completearchivetext.style.visibility="hidden";
ID_completearchivetext.style.display="none";
ID_completearchivetextenglish.style.visibility="hidden";
ID_completearchivetextenglish.style.display="none";
ID_englishheadline.style.visibility="hidden";
ID_englishheadline.style.display="none";
ID_englishsummary.style.visibility="hidden";
ID_englishsummary.style.display="none";
return (true);
}
}
else
{
if (doarticleedit.archived.checked==true)
{
with (document.all)
{
ID_PagesInArticle.style.visibility="hidden";
ID_PagesInArticle.style.display="none";
ID_pages.style.visibility="hidden";
ID_pages.style.display="none";
ID_expirydateforwebedition.style.visibility="hidden";
ID_expirydateforwebedition.style.display="none";
ID_livedateforarchiveversion.style.visibility="visible";
ID_livedateforarchiveversion.style.display="block";
ID_completearchivetext.style.visibility="visible";
ID_completearchivetext.style.display="block";
ID_completearchivetextenglish.style.visibility="visible";
ID_completearchivetextenglish.style.display="block";
ID_englishheadline.style.visibility="hidden";
ID_englishheadline.style.display="none";
ID_englishsummary.style.visibility="hidden";
ID_englishsummary.style.display="none";
return (true);
}
}
else
{
with (document.all)
{
ID_PagesInArticle.style.visibility="hidden";
ID_PagesInArticle.style.display="none";
ID_expirydateforwebedition.style.visibility="hidden"
ID_expirydateforwebedition.style.display="none";
ID_pages.style.visibility="hidden";
ID_pages.style.display="none";
ID_livedateforarchiveversion.style.visibility="hidden";
ID_livedateforarchiveversion.style.display="none";
ID_completearchivetext.style.visibility="hidden";
ID_completearchivetext.style.display="none";
ID_completearchivetextenglish.style.visibility="hidden";
ID_completearchivetextenglish.style.display="none";
ID_englishheadline.style.visibility="hidden";
ID_englishheadline.style.display="none";
ID_englishsummary.style.visibility="hidden";
ID_englishsummary.style.display="none";
return (true);
}
}
}
}
}

function validateform()
// Validate all form input
{
with (document.all)
{
// Headline
if (headline.value=="")
{
alert('ERROR! NO HEADLINE ENTERED');
headline.focus();
return (false);
}

// English Headline (if required)
if (bilingualavailable.checked)
{
if (englishheadline.value=="")
{
alert('ERROR! BILINGUAL ARTICLE SELECTED BUT NO ENGLISH HEADLINE ENTERED');
englishheadline.focus();
return (false);
}
}

// Summary
if (summary.value=="")
{
alert("No summary entered");
summary.focus();
return (false);
}

// English Summary (if required)
if (bilingualavailable.checked)
{
if (englishsummary.value=="")
{
alert("ERROR! BILINGUAL ARTICLE SELECTED BUT NO ENGLISH SUMMARY ENTERED");
englishsummary.focus();
return (false);
}
}

// Author not compulsary
/*
if (author.value=="")
{
alert("No author entered");
author.focus();
return (false);
}
*/

// Pages
if (pages.value=="")
{
alert("ERROR! PLEASE ENTER THE PAGE COUNT REQUIRED FOR THIS ARTICLE");
pages.focus();
return (false);
}

//expirydateforwebedition
if (weeklywebedition.checked)
{
if (expirydateforwebedition.value=="")
{
alert("ERROR! NO EXPIRY DATE FOR WEB VERSION ENTERED")
expirydateforwebedition.focus();
return (false);
}
}

// list date for archive
if (archived.checked)
{
if (livedateforarchiveversion.value=="")
{
alert("ERROR! NO LIVE DATE FOR ARCHIVE VERSION ENTERED")
livedateforarchiveversion.focus();
return (false);
}
}

// now mark the form as clean because we have validated and we're
// about to save it
formdirty=false;
return (true);

}
}

function markformdirty()
// Mark the form as dirty
{
formdirty=true;
}

function checkfordirty()
// Check to see if we want to leave the form because it is dirty
{
if (formdirty==true)
{
if(confirm("You have made changes to this article but have not saved it\nAre you sure you want to discard these changes?"))
{
return(true);
}
else
{
return(false);
}
}
else
return(true);
}

</script>

[email protected]
www.palomex.com
Interactive Website Design and Development

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

What error do you get? Which line? Smiling

Jack Michaelson's picture

He has: 1,733 posts

Joined: Dec 1999

I get the error in line 450. But I can't find out why

They have: 14 posts

Joined: Dec 2001

It's very annoying isn't it !
If I comment out the line, the error still seems to happen in the same place(albeit on a different line). When to me tends to hint that it's a problem with something else other than the line. I use InterDev for my coding and the "autocomplete" for objects brings up the ID_ things with no problem. Arggghghhghghghghhh

[email protected]
www.palomex.com
Interactive Website Design and Development

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

That could mean that the error is in the line of code above it. It could be a typo/missed bracket or semicolon.

I couldn't find anything myself... I had a heck of a time re-indenting the code to check for bracket errors but it's just too much work. Sad
I'll have a look again soon. Meanwhile, someone else might fix it. Smiling

They have: 14 posts

Joined: Dec 2001

The original one is all nicely indented and I've been down the bracket thing several times but couldn't spot it.

detox's picture

They have: 571 posts

Joined: Feb 2001

Andymac, that would have to be the longest code listing in the history of these forums!!! Just had a quick look but didn;t find anything, will try and comb through it to see what the problem is...

They have: 14 posts

Joined: Dec 2001

Hi,
Yeah, sorry about the size of the post (hence the original subject). But as my limited javascript experience has taught me that it's a very pedantic language, I thought I'd better copy the whole lot in ! I hope it's not a javascript parser bug... I've only tried it in IE, might try netscape.
cheers
Andy

[email protected]
www.palomex.com
Interactive Website Design and Development

detox's picture

They have: 571 posts

Joined: Feb 2001

first things first you had a couple of events being called incorrectly
as in java script not javascript. Still looking, am getting an error with a return true in the ID script......

They have: 14 posts

Joined: Dec 2001

Events being called incorrectly ? I'm never entirely sure if I should be doing things like;

onclick="javascript:myfunction();" or
onclick="javascript:myfunction;" or
onclick="javascript:myfunction()"

cheers
Andy

[email protected]
www.palomex.com
Interactive Website Design and Development

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.