Javascript 如何将tablesorter中的href值发送到对话框模式?

Javascript 如何将tablesorter中的href值发送到对话框模式?,javascript,php,jquery,pdo,tablesorter,Javascript,Php,Jquery,Pdo,Tablesorter,问题 我无法将tablesorter中的href值发送/传递到我的对话框模式。 当目标位置是对话框模式时,情况会变得复杂 示例(table.php) 这是我代码的一部分,因为上面是一个PDO PHP查询,用于从数据库获取数据重点是foreach内部的href代码 if($stmt->rowCount() > 0){ $r=$stmt->fetchAll(); echo "<table class='tablesorter-dropbox

问题

我无法将tablesorter中的href值发送/传递到我的对话框模式。 当目标位置是对话框模式时,情况会变得复杂

示例(table.php)

这是我代码的一部分,因为上面是一个PDO PHP查询,用于从数据库获取数据重点是foreach内部的href代码

    if($stmt->rowCount() > 0){
    $r=$stmt->fetchAll(); 
    echo "<table class='tablesorter-dropbox' id='myTable' style='width:97%; table-border: 1'>";
    echo "<thead>";
    echo "<tr style='text-align: center;'>";
    echo "<th style='text-align: center;'>No.</th>";
    echo "<th style='text-align: center;'>Conference Name</th>";
    echo "<th style='text-align: center;'>Conference Sponsor</th>";
    echo "<th style='text-align: center;'>Date (Start)</th>";
    echo "<th style='text-align: center;'>Date (End)</th>";
    echo "<th style='text-align: center;'>Budget</th>";
    echo "<th style='text-align: center;'>Status</th>";
    echo "<th style='text-align: center;'>Approve</th>";
    echo "<th style='text-align: center;'>Reject</th>";
    echo "</tr>";
    echo "</thead>";
    echo "<tbody>";
    
    
    //echo "<td><a href='reject.php?idstudent=".$row['matricno']."&idbook=".$row['serialno']."'><img src='pic/remove-icon-png-15.png' width=15px></a></td>";
    
    foreach ($r as $row){
        echo "<tr align='center'><td>".$row['id']."</td><td>". $row['conf_name'] ."</td><td>". $row['conf_sponsor'] ."</td><td>". $row['conf_fDate'] ."</td><td>". $row['conf_lDate'] ."</td><td>RM ". $row['conf_budget'] ."</td><td>". $row['conf_status'] ."</td><td><a href='#' onclick='this.href='indexSuperUser.php?idconf=".$row['id']."' role='button' data-toggle='modal' data-target='#login-modal3?idconf=".$row['id']."'><img src='images/good.png' width=15px></a></td><td><a href='#?idconf=".$row['id']."' role='button' data-toggle='modal' data-target='#login-modal4'><img src='pic/remove-icon-png-15.png' width=15px></a></td></tr>";
        //$startrow++;
    }

    echo "</tbody>";
    echo "</table>";
}
else{
    echo "<p align='center'>Nothing to show you :( I am really sorry for this T_T </p>";
}
if($stmt->rowCount()>0){
$r=$stmt->fetchAll();
回声“;
回声“;
回声“;
回音“否”;
呼应“会议名称”;
回声“会议赞助商”;
回声“日期(开始)”;
回音“日期(结束)”;
呼应“预算”;
回应“状态”;
回应“批准”;
回声“拒绝”;
回声“;
回声“;
回声“;
//回声“;
foreach($r作为$row){
回显“$row['id']”、$row['conf_name']”、$row['conf_赞助商']”、$row['conf_fDate']”、$row['conf_lDate']”、.RM.“$row['conf_预算']”、$row['conf_status']”;
//$startrow++;
}
回声“;
回声“;
}
否则{
echo“

没什么可给你看的:(我真的很抱歉这件事

”; }
示例#2(dialogmodal.php)

现在,我想在这里显示表中的变量。仅出于测试目的,我试图显示idconf,以查看id是否成功显示

    <!-- BEGIN # MODAL LOGIN -->
<div class="modal fade" id="login-modal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header" align="center">
                    <img style="position:relative; LEFT:20px; WIDTH:100px; HEIGHT:100px"  id="img_logo" src="images/logofpeNEW2.png">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                    </button>
                </div>
                
                <!-- Begin # DIV Form -->
                <div id="div-forms">
                    
                    <!-- Begin # Register Super User Form -->
                    <form id="approved-form">
                        <div class="modal-body">
                            <div id="div-register-msg">
                                <div id="icon-register-msg" class="glyphicon glyphicon-chevron-right"></div>
                                <span id="text-register-msg">Approve this event?.</span>
                            </div>
                            <input type="text" id="idconf" class="form-control" value="<?php echo $_GET['idconf']; ?>">
                        </div>
                        <div class="modal-footer">
                            <div>
                                <button type="submit" class="btn btn-primary btn-lg btn-block" style="background-color: green">Approve</button>
                            </div>
                        </div>
                    </form>
                    <!-- End # Register Super User Form -->
                    
                    
                </div>
                <!-- End # DIV Form -->
                
            </div>
        </div>
    </div>
    <!-- END # MODAL LOGIN -->
<!--END LOGIN AREAD--------------------------------->

批准此活动?。

哦,不要紧。我是通过使用别人提供的。我记不起链接了,但要感谢他提到使用“数据你的变量”,并使用jquery调用它,然后将它发送回模态对话框id。像这样

<a id='approved' href='#' role='button' data-toggle='modal' data-target='#login-modal3' data-id='".$row['idconf']."' data-confname='".$row['conf_name']."' data-confsponsor='".$row['conf_sponsor']."' data-conffdate='".$row['conf_fDate']."' data-confldate='".$row['conf_lDate']."' data-confbudget='".$row['conf_budget']."' data-confstatus='".$row['conf_status']."' data-useremail='".$row['email']."' data-username='".$row['name']."' data-balanceuser='".$row['balance']."' data-m='".$row['matricNo_fk']."'><img src='images/good.png' width=15px></a>
声明此变量后,在代码的下一行,将其发送到模式对话框id,例如

$(".modal-body #idconf").val( idconf );
$(".modal-body #nameconf").val( confname );
$(".modal-body #sponsorconf").val( confsponsor );
$(".modal-body #dateSconf").val( conffdate );
$(".modal-body #dateEconf").val( confldate );
$(".modal-body #budgetconf").val( confbudget );
$(".modal-body #statusconf").val( confstatus );
$(".modal-body #emailuser").val( useremail );
$(".modal-body #nameuser").val( username );
$(".modal-body #balanceuser").val( balanceuser );
$(".modal-body #m").val( m );
$('#addBookDialog').modal('show');
在模态对话框中,使用上面提到的id

<form id="approved-form">
                    <div class="modal-body">
                        <div id="div-register-msg">
                            <div id="icon-register-msg" class="glyphicon glyphicon-chevron-right"></div>
                            <span id="text-register-msg">Approve this event?.</span>
                        </div>
                        <input type="hidden" id="idconf" class="form-control" value="" disabled>
                        <input type="text" id="nameconf" class="form-control" value="" disabled>
                        <input type="text" id="sponsorconf" class="form-control" value="" disabled>
                        <input type="text" id="dateSconf" class="form-control" value="" disabled>
                        <input type="text" id="dateEconf" class="form-control" value="" disabled>
                        <input type="text" id="balanceuser" class="form-control" value="" disabled>
                        <input type="text" id="budgetconf" class="form-control" value="" disabled>
                        <input type="text" id="statusconf" class="form-control" value="" disabled>
                        <input type="text" id="emailuser" class="form-control" value="" disabled>
                        <input type="text" id="nameuser" class="form-control" value="" disabled>
                        <input type="hidden" id="m" class="form-control" value="" disabled>
                    </div>

批准此活动?。

我不是说这在速度或其他方面是有效的。但它解决了我的问题和用户问题。案例解决了

据我所知,您希望这个值
idconf=“.row['id']”。”
成为模式中
idconf
的值?问题是您只能得到
$\u get['idconf']
刷新页面后。因此,我建议不要像这样执行
数据目标='#login-modal3?idconf=“.$row['id']。”
为什么不将
idconf
分隔为
数据idconf='.$row['id']这样的操作呢“
然后使用jquery获取
数据idconf
,并将该值传递给
输入
。您可以用更少的代码做同样的事情,
var data=$(this.data();
,然后如果您必须将每个值添加到输入中,请使用
数据
作为对象引用数据,例如
$('.modal#m').val(data.m);
<form id="approved-form">
                    <div class="modal-body">
                        <div id="div-register-msg">
                            <div id="icon-register-msg" class="glyphicon glyphicon-chevron-right"></div>
                            <span id="text-register-msg">Approve this event?.</span>
                        </div>
                        <input type="hidden" id="idconf" class="form-control" value="" disabled>
                        <input type="text" id="nameconf" class="form-control" value="" disabled>
                        <input type="text" id="sponsorconf" class="form-control" value="" disabled>
                        <input type="text" id="dateSconf" class="form-control" value="" disabled>
                        <input type="text" id="dateEconf" class="form-control" value="" disabled>
                        <input type="text" id="balanceuser" class="form-control" value="" disabled>
                        <input type="text" id="budgetconf" class="form-control" value="" disabled>
                        <input type="text" id="statusconf" class="form-control" value="" disabled>
                        <input type="text" id="emailuser" class="form-control" value="" disabled>
                        <input type="text" id="nameuser" class="form-control" value="" disabled>
                        <input type="hidden" id="m" class="form-control" value="" disabled>
                    </div>