/    Sign up×
Community /Pin to ProfileBookmark

Could you help?

Hi guys,

This my first on this forum, i hope I’m posting this in the right section.

Please, I need a simple code that will change three texts located at different places on a web page, weekly (every Monday).

The replacement texts will may be listed (three lists) in the same code or link three external text files to the code.

Each list will contain 52 texts.

Preferably PHP or else JavaScript or both.

Thanks.

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@DewlanceDec 02.2015 — I think its a better to search in google for this type of script or hire a developer on from freelancing site since creating a script take lot of time.

I am still beginner but I can suggest you to use strip function or some function to limit text to 52 chars. I did not use php from last 1 year. ;/
Copy linkTweet thisAlerts:
@ginerjmDec 02.2015 — Your post probably makes great sense to you but it makes absolutely no sense to me. Try being a bit more detailed about what the h. you are trying to accomplish.

PS - do you currently know any php? If not, then you will be in need of a programmer and the advice above may be correct.
Copy linkTweet thisAlerts:
@BryanGauthorDec 02.2015 — Your post probably makes great sense to you but it makes absolutely no sense to me. Try being a bit more detailed about what the h. you are trying to accomplish.

PS - do you currently know any php? If not, then you will be in need of a programmer and the advice above may be correct.[/QUOTE]



How do i change below code to work weekly? Thanks.

</style>

<script type="text/javascript">

var quote=new Array();
quote[0]='This is quote number one';
quote[1]='This is quote number two';
quote[2]='This is quote number three';
quote[3]='This is quote number four';
quote[4]='This is quote number five';
quote[5]='This is quote number six';
quote[6]='This is quote number seven';
quote[7]='This is quote number eight';
quote[8]='This is quote number nine';
quote[9]='This is quote number ten';

var speed=2000;
var q=0;

function showQuote() {

document.getElementById("quotes").inner HTML=quote[q];
q++;
if(q==quote.length) {
q=0;
}
}
setInterval('showQuote()',speed);

</script>
Copy linkTweet thisAlerts:
@NogDogDec 02.2015 — Not claiming this is the best way or even the way I'd do it, but I [i]think[/i] it addresses your question?
[code=php]
<script type="text/javascript">

var quote=new Array();
<?php
$fh = fopen('path/to/quotes.txt', 'r');
$counter = 0;
while(($line = fgets($fh)) !== false)
{
echo 'quote['.$counter++."]='".htmlentities(trim($line))."';";
}
?>

var speed=2000;
var q=0;

function showQuote() {

document.getElementById("quotes").inner HTML=quote[q];
q++;
if(q==quote.length) {
q=0;
}
}
setInterval('showQuote()',speed);

</script>
[/code]
Copy linkTweet thisAlerts:
@BryanGauthorDec 02.2015 — Not claiming this is the best way or even the way I'd do it, but I [i]think[/i] it addresses your question?
[code=php]
<script type="text/javascript">

var quote=new Array();
<?php
$fh = fopen('path/to/quotes.txt', 'r');
$counter = 0;
while(($line = fgets($fh)) !== false)
{
echo 'quote['.$counter++."]='".htmlentities(trim($line))."';";
}
?>

var speed=2000;
var q=0;

function showQuote() {

document.getElementById("quotes").inner HTML=quote[q];
q++;
if(q==quote.length) {
q=0;
}
}
setInterval('showQuote()',speed);

</script>
[/code]
[/QUOTE]


Thanks for your kind response.

I got this from searching google;

Maybe you can just create an Array with all the texts, then make a Date object

dt=new Date();

and then do

dt.getDay();

and

dt.getMonth();

which will give you the current day and month and use those to calculate which one of the array to show...[/QUOTE]


Can you implement that?

Thanks
Copy linkTweet thisAlerts:
@NogDogDec 02.2015 — Looks like they're doing it all in JavaScript, not PHP. (This is the PHP sub-forum, after all. ? )
Copy linkTweet thisAlerts:
@BryanGauthorDec 03.2015 — Looks like they're doing it all in JavaScript, not PHP. (This is the PHP sub-forum, after all. ? )[/QUOTE]

Ok. is there any JavaScript version?
×

Success!

Help @BryanG 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,
)...