1,在用戶端計算
function calculate() { var obj = document.mod_form_det; var list_pr,price,disc_pct,disc; disc = parseFloat(obj.TextBox7.value); list_pr = parseFloat(obj.TextBox6.value); //若沒有折扣,則單價=報價價格;否則乘上折扣數 if (disc==0) { obj.TextBox8.value = list_pr; obj.TextBox10.value = list_pr; } else { disc_pct = disc/100; price = parseFloat(list_pr*(1-disc_pct)); // price = format_int(price); obj.TextBox8.value = price; obj.TextBox10.value = price; } document.mod_form_det.TextBox8.focus(); }
2,打開新窗口
function query_spec() { var qod_part = document.mod_form_det.tbPart.value; window.open("query_spec.aspx?qod_part="+qod_part,"query_spec","menubar=no,scrollbars=yes,width=720"); }
3,格式化數值
//格式化數值,取到小位數第4位 function format_int(g) { var f_int,point; f_int = g; f_int = f_int.toString() point = f_int.indexOf("."); point = point+5; f_int = f_int.substring(0,point); return f_int; }
4,讀取頁面中的元素
function count_freight() { var str = document.mod_form_det; var terms; var freight,fob,cif,c_f,price,cont_qty; terms = str.qo_terms.value; price = parseFloat(str.TextBox8.value); freight = parseFloat(str.TextBox10.value); cont_qty = parseInt(str.TextBox11.value); switch(terms) { case "0": str.TextBox12.value = ""; break; case "1": //FOB str.TextBox12.value = price; break; case "2": //CIF = FOB+(貨櫃運費/裝櫃數量)+保險(0.5%) cif = price+(freight/cont_qty)+((price + freight)*(5/1000)); cif = format_int(cif); alert(price + "+("+freight+"/"+cont_qty +")+(("+price+"+"+freight+")*("+5/1000+"))="+cif); str.TextBox12.value = cif; break; case "3": //C&F = FOB + (貨櫃運費/裝櫃數量) c_f = price + (freight/cont_qty); c_f = format_int(c_f); alert(price + "+(" + freight + "/" + cont_qty + ")=" + c_f); str.TextBox12.value = c_f; break; } }
5,讀取多選框
function enter_ok() { var obj,str,t_func,i; obj = ""; str = document.form1; for (i=0;i { if(str.elements[i].checked) { if(obj != "") { obj = obj + ";" + str.elements[i].value; } else { obj = obj + str.elements[i].value; } } } opener.document.mod_form_det.TextBox4.value=obj; opener.document.mod_form_det.TextBox5.focus(); self.close();
}
6,驗証輸入框的正確性
7,一進入畫面停留在第一個欄位
function window_onload() { form1.e_part.focus(); init(); }
8,隱藏框架
阅读(587) | 评论(0) | 转发(0) |