漂亮的前端控制項,漂亮控制項
一,status bootstrap提更的一個下拉控制項,但是它支援複選。。實現的方式是通過隱藏真實的checkbox,通過js將操作值傳遞給checkbox
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
Status
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1" style="width: 153px">
<li role="presentation">
<a class="aaa" role="menuitem" tabindex="-1" href="#" id="drafted" style="color:#CC9900">
<?php if($_GET['draft']):?>Drafted <span style='position: relative;right:-70px;'>√</span> //因為隱藏表單的提交方式是通過get所以我們可以擷取到操作值。
<?php else: ?>
Drafted
<?php endif; ?>
</a>
</li>
<li role="presentation">
<a role="menuitem" tabindex="-1" href="#" id="scheduled" style="color:green">
<?php if($_GET['scheduled']):?>Scheduled <span style='position: relative;right:-50px;'>√</span>
<?php else: ?>
Scheduled
<?php endif; ?>
</a>
</li>
<li role="presentation">
<a role="menuitem" tabindex="-1" href="#" id="published" style="color:blue">
<?php if($_GET['published']):?>Published <span s style='position: relative;right:-55px;'>√</span>
<?php else: ?>
Published
<?php endif; ?>
</a>
</li>
</ul>
js........................................................................
$("#drafted").click(function(){
//jQuery("#edit-draft").attr("checked", "checked");
jQuery("#edit-draft").click(); //點擊隱藏表單的那個checkbox
jQuery("#views-exposed-form-messages-page").submit(); //js 調用提交事件
jQuery("#edit-submit").click();
});
$("#scheduled").click(function(){
jQuery("#edit-scheduled").click();
jQuery("#views-exposed-form-messages-page").submit();
jQuery("#edit-submit").click();
});
$("#published").click(function(){
jQuery("#edit-published").click();
jQuery("#views-exposed-form-messages-page").submit();
jQuery("#edit-submit").click();
});
二,日期選取器
<div style="float: left;width: 40px;margin-right: 10px;margin-top: 5px;margin-left: 20px"><b>From:</b></div>
<div id="start_filter_date" class="input-append date" style="float:left">
<input size="16" type="text" class="input-small" readonly style="cursor: pointer" /><span class="add-on"><i class="icon-calendar"></i></span>
</div>
<div id="end_filter_date" class="input-append date" style="float:left;margin-left: 5px;">
- <input size="16" type="text" class="input-small" readonly style="cursor: pointer" /><span class="add-on"><i class="icon-calendar"></i></span>
</div>
<button class="date_submit icon-search btn btn form-submit" style="float:left;width:40px;margin-left: 5px;"></button>
js............................................................................................................................
$(".date_submit").click(function(){
//擷取選取器中時間值
var start_date = jQuery("#start_filter_date").find('input').val();
//將時間賦值給隱藏的表單項
jQuery("#start_date").attr("value",start_date);
var end_date = jQuery("#end_filter_date").find('input').val();
jQuery("#end_date").attr("value",end_date);
//然後出發提交按鈕
jQuery("#edit-submit").click();
});
//時間選取器的相關js函數
var current_date = new Date();
//current_date.setDate(current_date.getDate()-30);
current_date.setDate(current_date.getDate());
jQuery("#start_filter_date").datetimepicker({
format: 'M dd, yyyy',
autoclose: true,
startView: 2,
minView: 2,
maxView: 2,
startDate: 0,
endDate:current_date
});
jQuery("#end_filter_date").datetimepicker({
format: 'M dd, yyyy',
autoclose: true,
startView: 2,
minView: 2,
maxView: 2,
startDate: 0
//endDate: current_date
});
三,自動完成框
<div style="float: right">
<div style="float: left;width: 40px;margin-right: 31px;margin-top: 5px;"><b>Keyword:</b></div>
<input class="span2" data-provide="typeahead" data-source='' autocomplete="off" id="keyworld" type="text" placeholder="Enter keyword" style="float: left">
<button class="keyworld_submit icon-search btn btn form-submit" style="float:left;width:40px;margin-right: 0px"></button>
</div>
//其中data-source 的值是從資料庫調取出來的
js..................................................................................................
$(".keyworld_submit").click(function(){
var key = jQuery("#keyworld").val();
jQuery("#edit-title--2").attr("value",key);
jQuery("#edit-submit").click();
});
//如果data-source如果用js 賦值的話那麼,應該在整個dom 載入完成後就馬上被調用(不用什麼觸發事件才調用)
var source = jQuery("#edit-title--2").attr("data-source");
$("#keyworld").attr("data-source",source);
// 這是drupal擷取data-source 的方式
$form['title'] = array(
'#type' => 'textfield',
'#title'=> '',
'#attributes' => array(
'placeholder' => t('Search by campaign name'),
'data-provide' => t('typeahead'),
'data-source' => json_encode($arrMsg), //將數組轉化為json格式的
'autocomplete' => t('off')
),
'#prefix' => '<div class="span4 pull-left spacer10">',
);
//$arrMsg要求是普通數組
$results = db_query($queryString)->fetchAll();
$arrMsg = array();
foreach($results as $result){
array_push($arrMsg, $result->title);
}
做WEB前端,你用什工具?外掛程式?
Dreamweaver?Zend Studio?EditPlus?還有PS會用幾本就搞定了我現在也在做前端還需要學習下DIV+CSS
怎控制Div,使其顯示在頁面其他控制項的前端
a href=#與 a href=javascript:void(0) 的區別 開啟新視窗連結的幾種辦法
#包含了一個位置資訊
預設的錨點是#top 也就是網頁的上端
而javascript:void(0) 僅僅表示一個死連結
這就是為什麼有的時候頁面很長瀏覽連結明明是#可是
跳動到了頁首
而javascript:void(0) 則不是如此
所以呼叫指令碼的時候最好用void(0)
或者<input onclick>
<div onclick>等
開啟新視窗連結的幾種辦法
1.window.open('url')
2.用自訂函數
<script>
function openWin(tag,obj)
{
obj.target="_blank";
obj.href = "Web/Substation/Substation.aspx?stationno="+tag;
obj.click();
}
</script>
<a href="javascript:void(0)" onclick="openWin(3,this)">株洲</a>
window.location.href=""