简体   繁体   English

Javascript Onclick 2事件

[英]Javascript Onclick 2 events

I am looking for a unique solution for my issue. 我正在为我的问题寻找独特的解决方案。 I am looking to submit 2 events with 1 onclick. 我希望通过1个onclick提交2个事件。 The majority of answers involve creating a function() but part of my function involves using a php loop. 大多数答案都涉及创建一个function(),但是我的部分功能涉及使用php循环。

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? 您是否曾经考虑过使用AJAX? You could submit your form through AJAX. 您可以通过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 该链接可能会对您有所帮助: http : //www.jstiles.com/Blog/How-To-Submit-a-Form-with-jQuery-and-AJAX

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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