1、當(dāng)在一個(gè)文本框輸入內(nèi)容時(shí),下一個(gè)文本框自動(dòng)填寫上一個(gè)文本框輸入的內(nèi)容。簡單代碼如下:
????? <form name="fm" >
???????<input name="first" onpropertychange="fm.second.value=fm.first.value">
???????<input name="second">
????? </form>
2、enter鍵代替tab鍵。在控件的onkeydown事件中使用簡單的一行代碼即可:
????? if (window.event.keyCode==13) window.event.keyCode=9
3、強(qiáng)迫用戶讀取注冊協(xié)議的計(jì)時(shí)按鈕。主要是使用window.setTimeout()這個(gè)方法:
??????? var secs = 180;
??????? document.agree.agreeb.disabled=true;
??????? for(i=1;i<=secs;i++)
?????? {
????????????? window.setTimeout("update(" + i + ")",i*1000);//這里的計(jì)時(shí)嚴(yán)格來說不是很準(zhǔn)確
???????? }
???????? function update(num) {
?????????? if(num == secs) {
????????????? document.agree.agreeb.value ="同意";
????????????? document.agree.agreeb.disabled=false;
???????? }
??????? else {
??????????? printnr = secs-num;
?????????? document.agree.agreeb.value = "請認(rèn)真閱讀協(xié)議(" + printnr +" 后才能繼續(xù)注冊)";
???? }
4、文本框和file控件一起提交
????? 如果還是像原來的表單提交一樣,此操作是不可行的。什么原因不太清楚,錯(cuò)誤提示好像是語法方面的錯(cuò)誤。解決方法就得靠javascript了。另外就是提交按鈕換成一般的button,通過button調(diào)用一個(gè)函數(shù),最后通過表單名.submit()方法來提交。代碼簡單如下:
????? <form? method="post" name="fm">
???????? <input name="picname">
???????? <input type="file" name="pic">
???????? <input type="button" onclick="go()">
???? </form>
???? function go(){
???? var? picturename=fm.picname.value;
???? var? filename=fm.pic.value;
???? fm.action="test.jsp?pname="+picturename+"&fname="+filename;
???? fm.submit();
??? }
?5、兩個(gè)html頁面?zhèn)鬟f參數(shù)
?????? 使用js來接受 通過一個(gè)location.search就可以獲得后面的參數(shù)值
???? (to be continued)
????? <form name="fm" >
???????<input name="first" onpropertychange="fm.second.value=fm.first.value">
???????<input name="second">
????? </form>
2、enter鍵代替tab鍵。在控件的onkeydown事件中使用簡單的一行代碼即可:
????? if (window.event.keyCode==13) window.event.keyCode=9
3、強(qiáng)迫用戶讀取注冊協(xié)議的計(jì)時(shí)按鈕。主要是使用window.setTimeout()這個(gè)方法:
??????? var secs = 180;
??????? document.agree.agreeb.disabled=true;
??????? for(i=1;i<=secs;i++)
?????? {
????????????? window.setTimeout("update(" + i + ")",i*1000);//這里的計(jì)時(shí)嚴(yán)格來說不是很準(zhǔn)確
???????? }
???????? function update(num) {
?????????? if(num == secs) {
????????????? document.agree.agreeb.value ="同意";
????????????? document.agree.agreeb.disabled=false;
???????? }
??????? else {
??????????? printnr = secs-num;
?????????? document.agree.agreeb.value = "請認(rèn)真閱讀協(xié)議(" + printnr +" 后才能繼續(xù)注冊)";
???? }
4、文本框和file控件一起提交
????? 如果還是像原來的表單提交一樣,此操作是不可行的。什么原因不太清楚,錯(cuò)誤提示好像是語法方面的錯(cuò)誤。解決方法就得靠javascript了。另外就是提交按鈕換成一般的button,通過button調(diào)用一個(gè)函數(shù),最后通過表單名.submit()方法來提交。代碼簡單如下:
????? <form? method="post" name="fm">
???????? <input name="picname">
???????? <input type="file" name="pic">
???????? <input type="button" onclick="go()">
???? </form>
???? function go(){
???? var? picturename=fm.picname.value;
???? var? filename=fm.pic.value;
???? fm.action="test.jsp?pname="+picturename+"&fname="+filename;
???? fm.submit();
??? }
?5、兩個(gè)html頁面?zhèn)鬟f參數(shù)
?????? 使用js來接受 通過一個(gè)location.search就可以獲得后面的參數(shù)值
???? (to be continued)