/    Sign up×
Community /Pin to ProfileBookmark

problem doubling the scrip

hi,
my problem is very simple (i hope :rolleyes: ) but unsolvable for me ?

i found this nice, short and working countdown script and simply want to run two or more countdowns with it. i have doubled everything (head and body part) already and renamed the form and partly the variables but it did not work in the end…

here it is (unedited):


—————————

<script LANGUAGE=”JavaScript”>
<!–
var now = new Date();
var event = new Date(“Jan 1 2006 00:00:02”);
var seconds = (event – now) / 1000;
var minutes = seconds / 60;
var hours = minutes / 60;
var days = hours / 24;
ID=window.setTimeout(“update();”, 1000);
function update() {
now = new Date();
seconds = (event – now) / 1000;
seconds = Math.round(seconds);
minutes = seconds / 60;
minutes = Math.round(minutes);
hours = minutes / 60;
hours = Math.round(hours);
days = hours / 24;
days = Math.round(days);
document.form1.days.value = days;
document.form1.seconds.value = seconds;
ID=window.setTimeout(“update();”,1000);
}
// –>
</script>

<form name=”form1″ class=”buttonsend”>
<input type=”text” class=”buttonview” name=”days” value=”0″ size=”2″>
<input type=”text” name=”seconds” class=”buttonview” value=”0″ size=”8″>


—————————————————-

i’m glad about any usefull proposals. best it would be to show me some edited lines. my java script knowledge is ehm… limited ^^

thx
vaddibaer

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 04.2005 — You'll only need:

event1 and event2

form1 and form2

Everything else, in this case, can remain the same. However, use this editted script instead:
<i>
</i>&lt;script LANGUAGE="JavaScript"&gt;
&lt;!--
var event1 = new Date("Jan 1 2006 00:00:02");
var event2 = new Date("Dec 25 2005 00:00:02");
function update(c) {
var now = new Date();
var seconds = Math.round((window['event'+c] - now) / 1000);
var minutes = Math.round(seconds / 60);
var hours = Math.round(minutes / 60);
var days = Math.round(hours / 24);
document.forms['form'+c].days.value = days;
document.forms['form'+c].seconds.value = seconds;
window.setTimeout("update("+c+");",1000);
}
// --&gt;
&lt;/script&gt;

and use this BODY tag:
<i>
</i>&lt;body onload="
window.setTimeout('update(1)', 1000);
window.setTimeout('update(2)', 1000);
return true;"&gt;
Copy linkTweet thisAlerts:
@vaddibaerauthorApr 04.2005 — thank you for your help!

but there is still a problem


this works perfectly
<script LANGUAGE="JavaScript">

<!--

var event1 = new Date("Jan 1 2006 00:00:02");

var event2 = new Date("Dec 25 2005 00:00:02");

function update(c) {

var now = new Date();

var seconds = Math.round((window['event'+c] - now) / 1000);

var minutes = Math.round(seconds / 60);

var hours = Math.round(minutes / 60);

var days = Math.round(hours / 24);

document.forms['form'+c].days.value = days;

document.forms['form'+c].seconds.value = seconds;

window.setTimeout("update("+c+");",1000);

}

// -->

</script>

<body onload="

window.setTimeout('update(1)', 1000);

window.setTimeout('update(2)', 1000);

return true;">

<form name="form1" class="buttonsend">

<input type="text" class="buttonview" name="days" value="0" size="2">

<input type="text" name="seconds" class="buttonview" value="0" size="8">[/QUOTE]


Problem: I want to run three countdowns at once: (not working!)


<script LANGUAGE="JavaScript">

<!--

var [U][B]event1[/B][/U] = new Date("Jan 1 2007 00:00:02");

var [U][B]event2 [/B][/U] = new Date("Dec 25 2006 00:00:02");

var [B][U]event3[/U][/B] = new Date("Dec 25 2005 00:00:02");

function update(c) {

var now = new Date();

var seconds = Math.round((window['event'+c] - now) / 1000);

var minutes = Math.round(seconds / 60);

var hours = Math.round(minutes / 60);

var days = Math.round(hours / 24);

document.forms['form'+c].days.value = days;

document.forms['form'+c].seconds.value = seconds;

window.setTimeout("update("+c+");",1000);

}

// -->

</script>

<body onload="

window.setTimeout('update(1)', 1000);

window.setTimeout('update(2)', 1000);

window.setTimeout('update(3)', 1000);

return true;">


<form name="[B][U]form1[/U][/B]" class="buttonsend">

<input type="text" class="buttonview" name="days" value="0" size="2">

<input type="text" name="seconds" class="buttonview" value="0" size="8">

<form name="[B][U]form2[/U][/B]" class="buttonsend">

<input type="text" class="buttonview" name="days" value="0" size="2">

<input type="text" name="seconds" class="buttonview" value="0" size="8">

<form name="[B][U]form3[/U][/B]" class="buttonsend">

<input type="text" class="buttonview" name="days" value="0" size="2">

<input type="text" name="seconds" class="buttonview" value="0" size="8">

[/QUOTE]


where is my mistake?

thaks for your help

vaddibaer
Copy linkTweet thisAlerts:
@phpnoviceApr 04.2005 — You're missing closing FORM tags.
Copy linkTweet thisAlerts:
@vaddibaerauthorApr 05.2005 — excellent! a thousand thanks it works! --> nice code!
Copy linkTweet thisAlerts:
@phpnoviceApr 05.2005 — Cheers.
×

Success!

Help @vaddibaer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...