简体   繁体   中英

Javascript Onclick 2 events

I am looking for a unique solution for my issue. I am looking to submit 2 events with 1 onclick. The majority of answers involve creating a function() but part of my function involves using a php loop.

Currently this code only executes the 2nd event. Conversely if I switch the events the other event will occur. Basically whichever event is last will execute.

if($result){
    if(mysql_affected_rows() != 0){
      while($row = mysql_fetch_array($result)){ 

    echo "<table>";
        echo "<tr style='cursor: pointer' onclick=\"document.location = 'test.php?airport_id=" . $row['id'] . "'; document['myform'].submit(); return false; \";>";
    echo "<td width=100 align=left><font color=#FFFFFF>" . $row['ident'] . "</font></td>";

What do you suggest as a solution?

Have you ever think to use AJAX? You could submit your form through AJAX. After submission is Okay, trigger your redirect function; This link might help you: http://www.jstiles.com/Blog/How-To-Submit-a-Form-with-jQuery-and-AJAX

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM