/    Sign up×
Community /Pin to ProfileBookmark

DIV’s text change

Hi ?

Code in <STYLE>

[code]div.txt {background-color:#FFFFFF; width: 515px; height: 300px; overflow: scroll; margin-left: 240px; font-family: Verdana, Arial, sans-serif; font-style: italic; font-size: 10pt;}[/code]

<a href=”lalala.html” onClick=”[i]HELP[/i]“>next</a>

I’m in lalala.html
Let’s say I have the text “123” displayed in the div.
When the user clicks “next”, the onClick=”….” will work and the div’s text will change, NOTHING else..
How can I do this?
-tnx in adv

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@js_prof_consMar 27.2005 — Assuming the div's id is txt:&lt;a href="lalala.html" onclick="updateDiv('txt')"&gt;next&lt;/a&gt;Then add this code:&lt;script type="text/javascript"&gt;

var t = 0;
var msg = new Array(
"This will display 1. This should be the original text of the div.",
"This will display the first time next is clicked.",
"The second.",
"3rd"); /* Just add as many as you need.
Commas go after all but the last one */

function updateDiv(n) {
var d = document.getElementById(n);
t++
if(t==msg.length) t = 0;
d.firstChild.data = msg[t];
}

&lt;/script&gt;
Not tested, but it should work.
Copy linkTweet thisAlerts:
@UltimaterMar 27.2005 — Try
[code=html]
<script>
function somefunction(){
...
location.href="lalala.html"
}
</script>
<a href="javascript:void(0)" onclick="somefunction()">next</a>[/code]
Copy linkTweet thisAlerts:
@js_prof_consMar 27.2005 — Try
[code=html]
<script>
function somefunction(){
...
location.href="lalala.html"
}
</script>
<a href="javascript:void(0)" onclick="somefunction()">next</a>[/code]
[/QUOTE]
I'd leave the href in the anchor for those who don't have JavaScript enabled. I think the help is requested with the updating of the div, not the link.

Reading thru the post, if you don't want the link to go anywhere, it would be better using the above way, or just adding to my onclick event handler, ;return false . Don't forget the semicolon! Therefore, it would only link for those with JavaScript enabled.
×

Success!

Help @WebDevil 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...