Is there anyway to get a link to another part of your page (<a href="#link">
) to not refresh the page? Some times it will not refresh the page, and other times it will. This is a problem as i also have that link doing some javascript changes to the page onclick, which are then discareded when the page is refreshed at the same time.
Any ideas?
code snippet:
<script type="text/javascript">
function unhide(divID) {
var item = document.getElementById(divID);
if (item) {
item.className=(item.className=='hidden')?'unhidden':'hidden';
}
}
function unhidealways(divID){
var item = document.getElementById(divID);
if(item){
item.className='unhidden';
}
}
function fillreply(commentID){
var item = document.getElementById("replyto");
item.value=commentID;
}
function hide(divID){
var item = document.getElementById(divID);
if(item){
item.className='hidden';
}
var item2 = document.getElementById("replyto");
item2.value='';
}
</script>
...
echo "<br /><span class=\"replytext\"><a href=\"#makecom\" onclick=\"javascript:unhidealways('makecomment');unhidealways('makereply');fillreply('" . $row['Id'] . "');\">[reply]</a></span><br />";
...
<td>
<a name="makecom" />
<a href="javascript:unhide('makecomment');"><i>Discuss</i></a>
<div id="makecomment" class="hidden">
<form name="commentform" action="comment.php" method="post">
<div id="makereply" class="hidden">Reply to: <input type="text" size="6" name="replyto"/> <a href="javascript:hide('makereply');">[clear]</a></div>
<input type="hidden" name="pageid" value="<?php echo $pageid; ?>" />
<?php if(!$loggedin)
echo '<br /><a href="#TOP">Log In</a> or post as Anon<br /><br />';
else
echo '<br />';
?>
<textarea name="comment" rows="7" cols="40" ></textarea>
<input type="hidden" name="id" value="<?php echo $pageid; ?>" />
<br />
<input type="submit" value="Comment" />
</form>
</div>
</td></tr>