/    Sign up×
Community /Pin to ProfileBookmark

add remove innerhtml helllppppp

Hello all,this is my code:
i want when i call the [B]whatever function[/B] to show a message in valDiv place…
i made this…but i want before showing this message to delete the previous message [B]if exist[/B]
how can i do that…the problem i think is in function remove_show_message…
any ideas?or how else can be done this???

[code=php]
function whatever(){
….
….
….
….
….
remove_show_message();
show_message(errors);
}
[/code]

[code=php]
function show_message(errors) {
var ni = document.getElementById(‘valDiv’);
//var numi = document.getElementById(‘thevalValue’); this line may not be important
//var num = (document.getElementById(‘thevalValue’).value -1)+ 2; this line may not be important
//numi.value = num; this line may not be important
var newdiv = document.createElement(‘div’);
//var divIdName = ‘my’+num+’Div’; this line may not be important
//newdiv.setAttribute(‘id’,divIdName); this line may not be important
newdiv.innerHTML = errors;
ni.appendChild(newdiv);
}
function remove_show_message() {
XXXXXXXX //which would be the code here????
}
[/code]

[code=html]
<input type=”hidden” value=”0″ id=”thevalValue”/>
<div id=”valDiv”></div>
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ZeroKilledMar 19.2009 — i'm assuming you want to clear any present message or content in div valDiv. if so, you can use this simple line:
<i>
</i>var div = document.getElementById('valDiv');
while(div.firstChild)div.removeChild(div.firstChild);
Copy linkTweet thisAlerts:
@d_psimauthorMar 19.2009 — thnx mannnnnnn
×

Success!

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