# How to call 2 funcions on click?

**URL:** https://forum.kirupa.com/t/how-to-call-2-funcions-on-click/247268
**Category:** Uncategorized
**Created:** [December 20, 2007, 12:17pm UTC](https://forum.kirupa.com/t/how-to-call-2-funcions-on-click/247268 "2007-12-20T12:17:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![alapimba](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@alapimba](https://forum.kirupa.com/u/alapimba)
#### Post date: [December 20, 2007, 12:17pm UTC](https://forum.kirupa.com/t/how-to-call-2-funcions-on-click/247268/1 "2007-12-20T12:17:00Z")

</div>

Hello  
I’m with a few problems with some functions.  
It works if i have only one, but when i write the second an call it it don’t work.  
My function:

```auto
<?php do { $numero = $row_rs_anos['id']; ?>
function titulo<?php echo $numero ?>() {
 http.open("GET", "titulo<?php echo $numero ?>.html", true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('titulo').innerHTML = http.responseText;
   initLightbox();
    }
  }
  http.send(null);
}  
function replace<?php echo $numero ?>() {
  http.open("GET", "teste<?php echo $numero ?>.html", true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('imgs').innerHTML = http.responseText;
   initLightbox();
    }
  }
  http.send(null);
}
<?php } while ($row_rs_anos = mysql_fetch_assoc($rs_anos)); ?>

```

as you see the funcione titulo and the function replace are basicly the same, just change the page they open from and the div where it will appear… i don’t know if i should write it twice as i did or theres any better way…  
I’m calling it with:

```auto
<a href="javascript:replace<?php echo $row_rs_anos2['id']; ?>(); titulo<?php echo $row_rs_anos2['id']; ?>()"><?php echo $row_rs_anos2['ano']; ?></a>

```

What i’m doing wrong and how to fix it?  
Thanks
