【发布时间】:2022-01-23 19:48:12
【问题描述】:
有什么方法可以让我在重新加载页面后保持按钮处于活动状态? (我没有使用任何自定义 CSS,只有 Bootstrap) php。在 if 条件下,我将按钮用作打开或关闭的开关。
HTML
<div style="margin-top: 20px; margin-left: 40px;"><p> Show All Conferences </p>
<form method="POST">
<div class="tab-content">
<button style="margin-left: 35px;" type="submit" name="submitBtn" class="btn btn-primary" data-toggle="button"> On </button>
<button style="margin-left: -8px;" type="submit" name="submitBtn2" class="btn btn-secondary" data-toggle="button"> Off </button>
</form></div>
</div>
function switch_on_off()
{
$dateConf = date('Ymd');
if(isset($_POST['submitBtn'])) {
$dateConf = date("Y-m-d", strtotime('2017-02-02 17:02:03'));
}
if(isset($_POST['submitBtn2'])) {
$dateConf = date('Ymd');
}
return $dateConf;
}
function get_future_conferences()
{
$dateConf2 = switch_on_off();
$args = array(
'numberposts' => -1,
'post_type' => 'conference',
'post_status' => 'publish',
'meta_key' => 'conference_start_date',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
'key' => 'conference_start_date',
'value' => $dateConf2,
'compare' => '>=',
),
);
$conferences = get_posts( $args );
return $conferences;
{
【问题讨论】:
标签: php html wordpress button bootstrap-4