Solved

Help needed changing javascript code to delete unnecessary code.

Posted on 2014-11-25
7
98 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

777 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