僅一個(gè)form表單 js實(shí)現(xiàn)注冊(cè)信息依次填寫提交功能
我們?cè)仁且粋€(gè)很長(zhǎng)的form表單,里面有很多選項(xiàng)。客戶反饋這樣不夠友好,容易看花眼。因此進(jìn)行改進(jìn),實(shí)現(xiàn)多步驟進(jìn)度,多個(gè)提交的實(shí)現(xiàn)(其實(shí)只有一個(gè)form提交)。
實(shí)現(xiàn)的思路:將表單的選項(xiàng)裝入多個(gè)div中,一個(gè)顯示,其他隱藏。
實(shí)現(xiàn)效果如下:

1、JavaScript代碼
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-powerFloat.js"></script>
<link rel="stylesheet" href="css/powerFloat.css" type="text/css" />
<script type="text/javascript">
$(function() {
$(".pwdTrigger").powerFloat({
eventType : "focus",
targetMode : "remind",
targetAttr : "placeholder",
position : "2-1"
});
});
</script>
<script type="text/javascript">
function one() {
if (confirm("確定提交?")) {
$("#one").hide();
$("#two").show();
$("#grxx").attr("class","current_prev");
$("#zjxx").attr("class","current");
}
}
function two() {
if (confirm("確定提交?")) {
$("#two").hide();
$("#three").show();
$("#grxx").attr("class","done");
$("#zjxx").attr("class","current_prev");
$("#qzxx").attr("class","current");
}
}
function three() {
if (confirm("確定提交?")) {
$("#three").hide();
$("#four").show();
$("#grxx").attr("class","done");
$("#zjxx").attr("class","done");
$("#qzxx").attr("class","current_prev");
$("#qzfs").attr("class","current");
}
}
function reone() {
if (confirm("確定返回?")) {
$("#one").show();
$("#two").hide();
$("#grxx").attr("class","current");
$("#zjxx").attr("class","");
}
}
function retwo() {
if (confirm("確定返回?")) {
$("#three").hide();
$("#two").show();
$("#grxx").attr("class","current_prev");
$("#zjxx").attr("class","current");
$("#qzxx").attr("class","");
}
}
function rethree() {
if (confirm("確定返回?")) {
$("#four").hide();
$("#three").show();
$("#grxx").attr("class","done");
$("#zjxx").attr("class","current_prev");
$("#qzxx").attr("class","current");
$("#qzfs").attr("class","last");;
}
}
</script>
2、CSS代碼
<style type="text/css">
.flow_steps ul li { float:left; height:23px; padding:0 40px 0 30px; line-height:23px; text-align:center; background:url(img/barbg.png) no-repeat 100% 0 #E4E4E4; font-weight:bold;}
.flow_steps ul li.done { background-position:100% -46px; background-color:#FFEDA2;}
.flow_steps ul li.current_prev { background-position:100% -23px; background-color:#FFEDA2;}
.flow_steps ul li.current { color:#fff; background-color:#990D1B;}
.flow_steps ul li.last { background-image:none;}
</style>
3、HTML代碼
<body>
<table width="600px">
<tr>
<td>
<div class="flow_steps">
<ul style="list-style-type:none">
<li id="grxx" class="current">個(gè)人信息</li>
<li id="zjxx" >證件信息</li>
<li id="qzxx">簽注信息</li>
<li id="qzfs" class="last">取證方式</li>
</ul>
</div>
</td>
</tr>
<tr><td>
<form action="">
<div id="one">
<table align="center">
<tr>
<td>戶口所在地:</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸入戶口所在地" /></td>
</tr>
<tr>
<td>中文姓:</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸入中文姓" /></td>
</tr>
<tr>
<td>中文名:</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸入中文名" /></td>
</tr>
<tr>
<td>身份證號(hào):</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸入身份證號(hào)碼" /></td>
</tr>
<tr>
<td colspan="2">
<button type="button" onclick="one()">提交</button>
</td>
</tr>
</table>
</div>
<div id="two" style="display: none">
<table align="center">
<tr>
<td>通行證號(hào)</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸入證件號(hào)碼" /></td>
</tr>
<tr>
<td>有效日期至</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸入證件號(hào)碼" /></td>
</tr>
<tr>
<td>聯(lián)系電話</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸聯(lián)系電話,建議是手機(jī)號(hào)碼" /></td>
</tr>
<tr >
<td >
<button type="button" onclick="two()">提交</button>
</td>
<td>
<button type="button" onclick="reone()">上一步</button>
</td>
</tr>
</table>
</div>
<div id="three" style="display: none">
<table align="center">
<tr>
<td>簽注類別</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸入簽注類別" /></td>
</tr>
<tr>
<td>前往地</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸入前往地" /></td>
</tr>
<tr>
<td>簽證種類</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸入簽注種類" /></td>
</tr>
<tr >
<td >
<button type="button" onclick="three()">提交</button>
</td>
<td>
<button type="button" onclick="retwo()">上一步</button>
</td>
</tr>
</table>
</div>
<div id="four" style="display: none">
<table align="center">
<tr>
<td>取證方式</td>
<td><input class="pwdTrigger" type="text" placeholder="請(qǐng)輸入取證方式" /></td>
</tr>
<tr >
<td >
<button type="button" onclick="">提交</button>
</td>
<td>
<button type="button" onclick="rethree()">上一步</button>
</td>
</tr>
</table>
</div>
</form>
</td>
</tr>
</table>
</body>
</html>
源碼下載:http://xiazai.jb51.net/201606/yuanma/JavaScript-formshow(jb51.net).rar
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家學(xué)習(xí)JavaScript程序設(shè)計(jì)有所幫助。
- 用戶注冊(cè)常用javascript代碼
- javascript 清空form表單中某種元素的值
- Extjs學(xué)習(xí)筆記之三 extjs form更多的表單項(xiàng)
- js實(shí)現(xiàn)點(diǎn)擊注冊(cè)按鈕開始讀秒倒計(jì)時(shí)的小例子
- js簡(jiǎn)單實(shí)現(xiàn)用戶注冊(cè)信息的校驗(yàn)代碼
- form表單action提交的js部分與html部分
- Javascript和Java獲取各種form表單信息的簡(jiǎn)單實(shí)例
- jquery序列化form表單使用ajax提交后處理返回的json數(shù)據(jù)
- nodejs 實(shí)現(xiàn)模擬form表單上傳文件
- JS中的form.submit()不能提交表單的錯(cuò)誤原因
相關(guān)文章
ES6 let和const定義變量與常量的應(yīng)用實(shí)例分析
這篇文章主要介紹了ES6 let和const定義變量與常量的應(yīng)用,結(jié)合實(shí)例形式分析了ES6使用let定義變量以及使用const定義常量的相關(guān)操作技巧,需要的朋友可以參考下2019-06-06
完美解決手機(jī)網(wǎng)頁中輸入框被輸入法遮擋的問題
下面小編就為大家分享一篇完美解決手機(jī)網(wǎng)頁中輸入框被輸入法遮擋的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2017-12-12
利用momentJs做一個(gè)倒計(jì)時(shí)組件(實(shí)例代碼)
這篇文章主要介紹了利用momentJs做一個(gè)倒計(jì)時(shí)組件,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-12-12
利用Plupload.js解決大文件上傳問題, 帶進(jìn)度條和背景遮罩層
本篇文章主要介紹了c#+Plupload.js解決大容量文件上傳問題, 帶進(jìn)度條和背景遮罩層,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-03-03
解析javascript瀑布流原理實(shí)現(xiàn)圖片滾動(dòng)加載
這篇文章主要幫助大家解析javascript瀑布流原理,實(shí)現(xiàn)js圖片滾動(dòng)加載2016-03-03
交叉觀察器?IntersectionObserver用法詳解
這篇文章主要為大家介紹了交叉觀察器?IntersectionObserver用法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-10-10
javascript showModalDialog 多層模態(tài)窗口實(shí)現(xiàn)頁面提交及刷新的代碼
javascript 多層模態(tài)窗口showModalDialog頁面提交及刷新2009-11-11

