Solved

Help needed changing javascript code to delete unnecessary code.

Posted on 2014-11-25
7
94 Views
Last Modified: 2014-11-25
Hi,

I have a devision panel on my form called "counter" and the appearance set in the css:

#counter {
	position:absolute;
	left:10px;
	top:112px;
	width:150px;
	height:22px;
	text-align: left;
	color: #FFFFFF;
	font: 12px "Trebuchet MS", arial, sans-serif;
	font-weight: bold;
	z-index:6;
}

Open in new window


And on the devision "counter" I have inserted a javascript. that looks like this:

<!-- Begin

var showdate	= "yes"		// SHOW THE DATE ON THE PAGE

// START DATE SCRIPT

if (showdate == "yes") 
{
document.write('<div id="date-location">');
var d=new Date();
var weekday=new Array("Zondag","Maandag","Dinsdag","Woensdag","Donderdag","Vrijdag","Zaterdag");
var monthname=new Array("januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december");
document.write("<span class=\"date-font\"><nobr>" + weekday[d.getDay()] + " ");
document.write(d.getDate() + " ");
document.write(monthname[d.getMonth()] + " ");
document.write(d.getFullYear());
document.write("</nobr><br></span>");
document.write('</div>');
}
else {
document.write('&nbsp;<br>');
}
document.write('</td><td align="right">');

//  End -->

Open in new window


The code was used with tables , but I don't use tables anymore now I use devisions. What code
can be erased? And I don't use division "date-location" and class "date-font" anymore so that
should be erased too. Can anyone help me to change the code because its to hard for me to
understand. And the appearance of the devision cannot be changed.

Who can help me with erased the unnecessary code?

Greetings,
Peter Kiers
0
Comment
Question by:peterkiers
  • 5
  • 2
7 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 40464596
I guess you can delete Line 20-21-22-23-24 and put ";" at the end of line 19
0
 
LVL 1

Author Comment

by:peterkiers
ID: 40464603
Oke and what about the declarartion of  "date-location" and class "date-font" that i don't use anymore? p.
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 40464626
document.write('<div id="date-location">');

can stay as is... or

document.write('<div>');

document.write("<span class=\"date-font\"><nobr>" + weekday[d.getDay()] + " ");
>>>
document.write("<span><nobr>" + weekday[d.getDay()] + " ");
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

Expert Comment

by:HainKurt
ID: 40464636
a bit confused... where is "id=counter"?

maybe you should do this:

document.write('<div id="date-location">');
>>>
document.write('<div id="counter">');
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 40464644
if you are writing all code above inside div id=counter, then you can delete these two lines as well...

document.write('<div id="date-location">');
document.write('</div>');

assuming you are doing this:

<div id="counter">
>>> script above comes here <<<
</div>
0
 
LVL 1

Author Comment

by:peterkiers
ID: 40464660
Thank it works fine. Greetings, Peter Kiers
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 40464679
why average? should I connect to your server and do all typing & test myself to get "Excellent" :)

and you got the answer in 25 minutes (time between first post & the one which is accepted)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now