2013-12-13 28 views
0

我有一個延遲費用的表格,我想在特定日期和時間後自動添加。如何在特定的日期和時間之後預先檢查複選框?

我們使用的腳本需要複選框和表單上每個項目的金額字段。因此,滯納金有一個複選框,當選中時,$ 25出現在隨行字段中。此費用將被添加到表格上的其他費用中。

我想用css隱藏Late Fee複選框(但留下其附帶的文本),並且在特定日期/時間後在金額字段中顯示25美元的滯納金。

我已經有一個隱藏字段來收集當前日期,如果這對解決方案有用。 (「)

我希望我已經解釋了這不夠好。如果要求這樣做,我會澄清。

...我已經尋找了一段時間,試圖找到一個答案,都無濟於事。出來希望能天使有可能幫助我謝謝

+0

你爲什麼不把它放在與PHP在那個特定的時間? – Lithilion

回答

0

這是否幫助我不是100%肯定,如果這是你想要做什麼

<?php 

# Get a DateTime obj for the late date (christmas in this case) 
$lateDate = DateTime::createFromFormat("d-m-Y", "25-12-2013", new DateTimeZone("Pacific/Auckland")); 

# The date now 
$now = new DateTime("now", new DateTimeZone("Pacific/Auckland")); 

# Get a boolean for whether it's late or not 
$isLate = ($now->getTimestamp() > $lateDate->getTimestamp()); 
?> 

<? if ($isLate): ?> 
You're late!!! 
<? endif; ?> 

<input type="checkbox" name="lateFee" value="25" <?=($isLate ? 'checked="checked"' : '')?> /> 
0

沒有看到任何代碼,怎麼樣:。?。

$today = new DateTime(); 
$lateFee = null; 
$hide = null; 
if($today > $cutOffDate){ 
    $lateFee = 'value="25.00"'; 
    $hide = 'hide'; 
} 
echo '<input type="number" step="any" name="lateFee" ',$lateFee,'>'; 
echo '<input type = "checkbox" name="lateFeeCheckbox" class="',$hide,'">'; 

在你的CSS,你可以用它躲來躲去的「隱藏」類中的任何輸入

相關問題