点击显示或隐藏:
---html部分
<td width="50" id="TDmonth">
<%
Response.Write "<input type=""radio"" name=""radiobutton"" value=""year"" onClick=""show('none');"">年度"
Response.Write "<input type=""radio"" name=""radiobutton"" value=""month"" onClick=""show('block');"" checked>月"
%>
</td>
---JavaScript部分
<SCRIPT LANGUAGE="JavaScript">
function show(para){
TDmonth.style.display=para;
}
</SCRIPT>
打开一个窗口
<SCRIPT LANGUAGE="JavaScript">
function disp(url){
window.open(url, "カレンダー問い合わせ", "width=250,height=400,scrollbars=yes,resizable=yes,status=yes");
}
</SCRIPT>
给控件赋值并提交
<SCRIPT LANGUAGE="JavaScript">
function update_submit(){
if ( jf_FormInputChk() != false ){
document.forms('frmSubmit').EADDCHK.value="update";
document.forms('frmSubmit').submit();
}
}
</SCRIPT>
框架页的跳转
<SCRIPT LANGUAGE="JavaScript">
function jf_update(id){
top.location.href="mp10215500_frame.asp?Rq_id="+id;
}
</SCRIPT>
单选按钮:选中与不可选的属性设置
<SCRIPT LANGUAGE="JavaScript">
function Radio_style(type){
if(type=='1'){
document.forms('frmSubmit').rad_page1.checked="ture";
document.forms('frmSubmit').rad_page2.disabled="ture";
}
else{
document.forms('frmSubmit').rad_page1.checked="";
document.forms('frmSubmit').rad_page2.disabled="";
}
if(type=='2'){
document.forms('frmSubmit').rad_page2.checked="ture";
document.forms('frmSubmit').rad_page1.disabled="ture";
}
else{
document.forms('frmSubmit').rad_page2.checked="";
document.forms('frmSubmit').rad_page1.disabled="";
}
if(type=='3'){
document.forms('frmSubmit').rad_page3.checked="ture";
document.forms('frmSubmit').rad_page1.disabled="ture";
document.forms('frmSubmit').rad_page2.disabled="ture";
}
else{
document.forms('frmSubmit').rad_page3.checked="";
}
}
function style_clear(type){
if(type=='1'){
document.forms('frmSubmit').rad_page3.checked="";
}
if(type=='3'){
document.forms('frmSubmit').rad_page1.checked="";
document.forms('frmSubmit').rad_page2.checked="";
}
}
</SCRIPT>
弹出警告并选中
<SCRIPT LANGUAGE="JavaScript">
function Check(id){
if (!CheckDate(document.all("text_HokenStartDate_" + id).value))
{ validity = false;
alert('保険開始日が不正です');
document.all("text_HokenStartDate_" + id).select();
}
</SCRIPT>
判断是否为数字
<SCRIPT LANGUAGE="JavaScript">
function CheckNum(NUM){
var i,j,strTemp;
strTemp="0123456789,";
if ( NUM.length== 0)
return false;
for (i=0;i<NUM.length;i++)
{
j=strTemp.indexOf(NUM.charAt(i));
if (j==-1)
{
return false;
}
}
return true;
}
</SCRIPT>
动态添加组件
---JavaScript部分
<script language="javascript">
var curRow=null;
function selectRow(){
var e=window.event;
var tr1=e.srcElement;
if(curRow)
curRow.bgColor="#FFFFFF";
tr1.bgColor="e7e7e7";
curRow=tr1;
}
function addRow(src){
//alert(src);
var newrow = src.insertRow(src.rows.length-1);
newrow.attachEvent("onclick",selectRow);
newrow.height=20;
var i=4;
while(i--){
var newcell = newrow.insertCell();
switch(i){
case 0: newcell.innerHTML= '<input type="button" onClick="javascript:delRow(this.parentElement.parentElement)" value="delete this row">';break;
default: newcell.innerHTML=div1.innerHTML;break;
}
}
alert(newrow.outerHTML);
}
function delRow(src){
var tab=src.parentElement;
var i=tab.rows.length;
while(i--){
if(src==tab.rows[i]){
alert("this row----"+ i);
tab.deleteRow(i);
}
}
}
</script>
---html部分
<body>
<table id="tb" width="100%" border="1" align="center" cellpadding="1" cellspacing="1" style="border-collapse:collapse" bordercolor="#111111">
<tr>
<th scope="col" width="25%">milk</th>
<th scope="col" width="25%">shuliang</th>
<th scope="col" width="25%">zhongliang</th>
<th scope="col" width="25%">danjia</th>
</tr>
<tr id="blankRow" onClick="addRow(this.parentElement)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<div id="div1" style="display:none "><input id="txt" type="text" style="width:97%; background-color:#FFFFEF"></div>
</body>
</html>
隐藏及变色
---html部分
<body>
<p class="style1"><a onClick="show()" style="cursor:pointer" onMouseOver="change(0)" onMouseOut="change(1)"><font id="c1">click here</font></a></p>
<table width="326" height="58" border="0" bgcolor="#666666" id="t1" style="display:none">
<tr>
<td bgcolor="#9999CC"><div align="center">name</div></td>
<td bgcolor="#9999CC"> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="66"><div align="center">royal </div></td>
<td width="250"> </td>
</tr>
</table>
---JavaScript部分
<SCRIPT LANGUAGE="JavaScript">
function show(){
if (t1.style.display == "none"){
t1.style.display = "";
}
else{
t1.style.display = "none";
}
}
function change(para){
if (para == "0"){
c1.color = "#999999";
}
else{
c1.color = "#000000";
}
}
</SCRIPT>
</body>