Jump to content

how to call 2 funcions on click?


alapimba

Recommended Posts

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:

<?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:

<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

 

Link to comment
Share on other sites

call two functions in one - some like:

 

<script language="javascript">

<?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)); ?>

function doAll() {
replace<?php echo $row_rs_anos2['id']; ?>();
titulo<?php echo $row_rs_anos2['id']; ?>();
}

</script>

<a href="javascript://" onlick="doAll()"><?php echo $row_rs_anos2['ano'];  ?></a>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.