我有一个表显示数据库中的一些数据。如果我想显示5,10或20个结果,我希望能够从下拉列表中进行选择。我已经创建了一个下拉列表。我想的是创建一个onClick事件,改变$ config的值[" per_page"] = 20;但我不知道该怎么做。我的分页配置文件是一个名为pagination.php的文件
这是我的观点:
<div class="portlet box blue-madison">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-bank"></i>Notifications
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
<!--<a href="#portlet-config" data-toggle="modal" class="config"></a>-->
<a href="javascript:;" class="reload"></a>
<!--<a href="javascript:;" class="remove"></a>-->
</div>
</div>
<div class="portlet-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="logs">
<thead>
<tr role="row" class="heading">
<th>
#
</th>
<th>
Date
</th>
<th>
Destinataire
</th>
<th>
Message
</th>
<th>
Expéditeur
</th>
</tr>
<tr role="row" class="filter">
<form class="filter" id="frm-flt-log_send" onsubmit="return false;">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>
<!--<div class="margin-bottom-5">
<button class="btn btn-sm green btn-outline filter-submit margin-bottom" onclick="loadCompanies('<?php //echo site_url('notifications/main/lst')?>')"><i class="fa fa-search"></i> Filtrer</button>
</div>
<button class="btn btn-sm red btn-outline filter-cancel" onclick="this.form.reset();loadLog_send();"><i class="fa fa-times"></i> Reset</button>-->
</td>
</form>
</tr>
</thead>
<tbody id="log_send-ajax-content">
<?php $this->load->view('log_send/list_ajax.php');?>
</tbody>
</table>
</div>
</div>
<div class="portlet-body">
<img class ="ico" src="<?php echo base_url(); ?>assets/images/gris.png"> Etat inconnu
<img class ="ico" src="<?php echo base_url(); ?>assets/images/bleu.png"> Notification envoyée
<img class ="ico" src="<?php echo base_url(); ?>assets/images/vert.png"> Notification reçue
<img class ="ico" src="<?php echo base_url(); ?>assets/images/rouge.png"> Erreur dans l'envoi
</div>
<div class="portlet-body">
<img class ="ico" src="<?php echo base_url(); ?>assets/images/ok.png"> Quittance OUI
<img class ="ico" src="<?php echo base_url(); ?>assets/images/nok.png"> Quittance NON
<img class ="ico" src="<?php echo base_url(); ?>assets/images/unkown.png"> Non quittancé (raccroché)
</div>
</div>
数据传递到表中:
<?php
foreach ($content as $value){
switch($value->id_send_type){
case "1": // SMS
switch ($value->etat){
case "Msg read complete":
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/sms_vert.png\">";
break;
case "Msg send complete":
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/sms_bleu.png\">";
break;
case "Msg Pending":
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/sms_orange.png\">";
break;
default:
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/sms_gris.png\">";
break;
}
$quittance = "<img id=\"q".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/vide.png\">";
break;
case "2": // Email
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/mail_bleu.png\">";
$quittance = "<img id=\"q".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/vide.png\">";
break;
case "3": //Appel vocaux
switch ($value->etat) {
case 'ring':
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/appel_ring.png\">";
break;
case 'hangup':
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/appel_vert.png\">";
break;
default:
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/appel_bleu.png\">";
break;
}
switch ($value->quittance) {
case '1':
$quittance = "<img id=\"q".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/ok.png\">";
break;
case '3':
$quittance = "<img id=\"q".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/nok.png\">";
break;
case '9':
$quittance = "<img id=\"q".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/unkown.png\">";
break;
default:
$quittance = "<img id=\"q".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/vide.png\">";
break;
}
break;
case "4": // Pager
switch ($value->etat){
case "Msg read complete":
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/pager_vert.png\">";
break;
case "Msg send complete":
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/pager_bleu.png\">";
break;
case "Msg Pending":
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/pager_orange.png\">";
break;
default:
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/pager_gris.png\">";
break;
}
$quittance = "<img id=\"q".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/vide.png\">";
break;
case "5": //Threema
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/threema_bleu.png\">";
$quittance = "<img id=\"q".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/vide.png\">";
break;
case "7": //Fax
switch ($value->etat) {
case '0':
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/fax_vert.png\">";
break;
default:
$etat = "<img id=\"".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/send_type/fax_bleu.png\">";
break;
}
$quittance = "<img id=\"q".$value->ticket."\" class=\"ico\" src=\"".base_url()."/assets/images/vide.png\">";
break;
}
echo "<tr><td>".$etat.$quittance."</td><td>".$value->date."</td><td>".$value->recname." ".$value->recfirstname."<br><font size=\"0.5em\"><i>".$value->recipient."</i></font></td><td>".$value->message."</td><td>".$value->expname." ".$value->expfirstname."</td>";
//echo '<td>' . (($value->active)?'<span class="badge badge-success">on</span>':'<span class="badge badge-danger">off</span>') . '</td>';
//echo '<td><button class="btn btn-info" type="button" onClick="window.location.href = \'' . site_url('admin/company/edit/' . $value->id_company) . '\';">Modification</button></td>';
echo '</tr>';
}
?>
<tr>
<td colspan="8">
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Résultats par page
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="#">5</a></li>
<li><a href="#">10</a></li>
<li><a href="#">20</a></li>
</ul>
</div>
<div id="pagination"><?php echo $pag_links; echo $pag_total ;?></div>
</td>
</tr>
答案 0 :(得分:0)
回答“如何捕捉点击事件”的问题:
<select onchange='doSomething(this)'>
<option value='5'>5</option>
<option value='10'>10</option>
<option value='15'>15</option>
</select>
<script type='text/javascript'>
function doSomething(elem) {
alert('value = ' + elem.value);
}
</script>
现在,如果您需要根据所选的数量显示不同的行数,则需要使用javascript进行更多操作。如果您使用jQuery,您的生活会更轻松。
无论如何,重新发明轮子毫无意义。看看datatables,因为它们完全符合您的要求。
祝你好运