/    Sign up×
Community /Pin to ProfileBookmark

changing text

Does anyone know where I can find a script to dynamically change the text based on the date or the the users IP, I want something where I can have the text change (such as things that are being offered on the site) everyday without me having to go into the code and change it everyday. Is something like this possible? Thanks!

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@NevermoreJul 28.2003 — Yes. Here's an example - I don't know if it's any use to you.

[CODE]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
var dmy = "Today's Date: "+day+"/"+month+"/"+year
// -->
</script>
</head>
<body onload="document.getElementById('dmy').firstChild.nodeValue=dmy">
<a id="dmy">If you have JavaScript, the date will be displayed here.</a>
</body>
</html>
[/CODE]
Copy linkTweet thisAlerts:
@r00tsecauthorJul 29.2003 — Yeah, I am still a little conufsed. Say you wanted a pice of text with the following strings to change everyday, or based off the users IP. "Hello World" "Hello World Two" "Hello World Three". How would I write the JS to switch this dynamically?
Copy linkTweet thisAlerts:
@CharlesJul 29.2003 — [font=monospace]<script type="text/javascript">

<!--

messages = ['Hello World One', 'Hello World Two', 'Hello World Three'];

document.write('<p>', messages[new Date().getDate() % messages.length], '</p>')

// -->

</script>[/font]
Copy linkTweet thisAlerts:
@r00tsecauthorJul 29.2003 — thanks!
Copy linkTweet thisAlerts:
@r00tsecauthorJul 29.2003 — ok, im sorry, im new to JS, but I was wondering how would you go about changing the font color in the above code?
Copy linkTweet thisAlerts:
@CharlesJul 29.2003 — [font=monospace]<script type="text/javascript">

<!--

messages = ['Hello World One', 'Hello World Two', 'Hello World Three'];

document.write('<p style="color:#900">', messages[new Date().getDate() % messages.length], '</p>')

// -->

</script>[/font]
Copy linkTweet thisAlerts:
@r00tsecauthorJul 29.2003 — thanks so much!?
×

Success!

Help @r00tsec 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.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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