View Full Version : Showing and Hiding divs using javascript problem

04-09-2005, 04:53 PM
on my web page i have made it so you can click on a link and a hidden div will appear. the problem is that it only appears for a split second the dissappears again. can anyone tell me what im doing wrong?

here eis the javascript i used

function getObj(idvalue) {
if (document.getElementById) this.style = document.getElementById(idvalue).style;
else if (document.layers) this.style = document.layers[idvalue];

function replies(num) {
var rep = 'reply' + num;
reply = new getObj(rep);
if (reply.style.display == 'block') reply.style.display = 'none';
else reply.style.display = 'block';

here is the web page it is to


04-09-2005, 05:29 PM
because you are using anchor elements to envoke the script, after the script is done executing the anchor reloads the page. Unless there is a default anchor action when JS is disabled, do not use anchors for script envocation. Any element can have onclick, otherwise make sure that your event handling function returns false so that the default action is interrupted