JQUERY
1. Event 2. Traversing 爬樹 2-1 JQuery - $.each如何做到continue, break 3. DOM manipulate 4. jquery.validate 4-1 檢查公司編號是否重覆 5. 子母視窗 5-1 進貨單明細 - 商品子視窗 5-2 進貨單明細 - 商品子視窗(2) 5-3 進貨單主檔 - 廠商資料 6. form 6-1 判斷 checkbox 是否選取,實現全選跟全部取消 7. 指令
母視窗表單
<!--廠商編號-->
<div class='col-md-3'>
<div class='form-group'>
<label for='vendor' class='control-label'>廠商編號</label>
<div class="input-group mb-2">
<input type="text" class="form-control" id="vendor" name='vendor' value="<{$row.vendor}>" readonly>
<div class="input-group-prepend">
<div class="input-group-text">
<a href="javascript:void(0)" class="vendorWin" >
...
</a>
</div>
</div>
</div>
</div>
</div>
<!--廠商名稱-->
<div class='col-md-3'>
<div class='form-group'>
<label for='vendor_title' class='control-label'>廠商名稱</label>
<div class="input-group mb-2">
<input type="text" class="form-control" id="vendor_title" name='vendor_title' value="<{$row.vendor_title}>" readonly>
<div class="input-group-prepend">
<div class="input-group-text">
<a href="javascript:void(0)" class="vendorWin" >
...
</a>
</div>
</div>
</div>
</div>
</div>
母視窗按鈕
//廠商視窗
$(".vendorWin").click(function(){
vendorWin('purchase.php?op=vendorWin',300,300);
});
母視窗函數
//子視窗函數
function vendorWin(imgName,imgH,imgW)
{
screenWidth = screen.width;//取得螢幕寬度
rightPosition = screenWidth - imgW - 20; // 計算視窗右上位置
mywin=window.open("","","left="+ rightPosition +",top=100,width=" + imgW + ",height=" + imgH + ",location=no");
mywin.location.href = imgName + "&sn=" + document.getElementById('vendor').value;
}
從子視窗設定母視窗的元素(後來沒用)
var vendor = document.getElementById('vendor');
window.opener.document.getElementById('vendor').value = vendor.value;
window.opener.document.getElementById('vendor_title').value = vendor.options[vendor.selectedIndex].text;
//window.opener.getAjaxVendor(sn);
子視窗函數
<script>
function senddata()
{
var vendor = document.getElementById('vendor');
var sn = vendor.value;
var old_sn = window.opener.document.getElementById('vendor').value;
if(window.opener.document && sn != old_sn){
window.opener.getAjaxVendor(sn);//run 母視窗的方法
}
window.close();//結束子視窗
}
</script>
子視submit
<select name='vendor' id='vendor' class='form-control' size='5'>
$option
</select>
<input type='button' value='送出' onClick='senddata()' />
參考 modules/umg_stk/purchase.php -> vendorWin($sn)、getAjaxVendor($sn)