0

and thanks to anyone who can help me!

I have a text with this code:

<a onclick="return showPic(this); mostrarespectacular()" href="Imatges/productosnuevos/urbano01.jpg">&nbsp Circuito Espectacular Barcelona</a>

and the scripts are:

<script type="text/javascript">
function showPic (whichpic) {
 if (document.getElementById) {
  document.getElementById('imgContenedor').src = whichpic.href;
  if (whichpic.title) {
      document.getElementById('imgDescripcion').childNodes[0].innerHTML = whichpic.innerHTML;
  }
  return false;
 } else {
  return true;
 }
}
</script>
<script type="text/javascript">
function mostrarespectacular() {
    div = document.getElementById('circuloespectacular');
    div.style.display = 'inline';
}
function cerrarespectacular() {
    div = document.getElementById('circuloespectacular');
    div.style.display='none';
}
</script>

and my problem is that the first function works perfect but not the second one (which has to show a div). Any ideas of what i'm doing wrong? Thanks!!

2 Answers 2

2

You return from the onclick after the first function call. Remove that and you should be fine.

Sign up to request clarification or add additional context in comments.

1 Comment

mmmm no, if I delete "return" the image i need to see in a div, opens in the same page! I solved the problem just changing the order of the functions!!!!
1

The "return" is branching out of the script after calling the showPic() function. Remove the return or place it before the "mostrarespectacular()" call or move it to the end, etc.

1 Comment

@Adam had the same conclusion. I just didn't see that response until I had posted mine. : ) Glad you got it working anyway!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.