一个基于HTML与JavaScript的Wizard演示

简介: 一个基于HTML与JavaScript的Wizard演示

整个过程模仿用户注册,分为三步完成,运行效果如下:

1348825061_3808.png

全部代码如下:

<html>
<head>
    <title>JavaScript Create User Wizard Example</title>
    <script type="text/javascript">
      function handleWizardNext()
        {
            if (document.getElementById('ButtonNext').name == 'step2')
            {
              document.getElementById('step1').style.display = 'none';
                document.getElementById('step2').style.display = '';
        document.getElementById('ButtonNext').name = 'step3';
 
                document.getElementById('ButtonPrevious').name = 'step1';
                document.getElementById('ButtonPrevious').disabled = '';
 
                document.getElementById('headstep1').style.backgroundColor = 'silver';
                document.getElementById('headstep2').style.backgroundColor = 'white';
            }
            else if(document.getElementById('ButtonNext').name == 'step3')
            {
              document.getElementById('step2').style.display = 'none';
                document.getElementById('step3').style.display = '';
 
        document.getElementById('ButtonNext').name = '';
        document.getElementById('ButtonNext').disabled = 'disabled';
 
        document.getElementById('ButtonPrevious').name = 'step2';
                document.getElementById('ButtonPrevious').disabled = '';
        document.getElementById('SubmitFinal').disabled = '';
 
        document.getElementById('headstep2').style.backgroundColor = 'silver';
                document.getElementById('headstep3').style.backgroundColor = 'white';
            }
 
        }
 
        function handleWizardPre() {
          // console.log("this is to go back previous page");
          if (document.getElementById('ButtonPrevious').name == 'step1') {
            // display/hide the relevative fieldset
            document.getElementById('step2').style.display = 'none';
                document.getElementById('step1').style.display = '';
 
                // enable/disable buttons
        document.getElementById('ButtonNext').name = 'step2';
        document.getElementById('ButtonPrevious').name = '';
                document.getElementById('ButtonPrevious').disabled = 'disabled';
                document.getElementById('SubmitFinal').disabled = 'disabled';
                document.getElementById('SubmitFinal').name = '';
 
                // change navigation color
                document.getElementById('headstep2').style.backgroundColor = 'silver';
                document.getElementById('headstep1').style.backgroundColor = 'white';
 
          } else if(document.getElementById('ButtonPrevious').name == 'step2') {
            // display/hide the relevative fieldset
            document.getElementById('step3').style.display = 'none';
                document.getElementById('step2').style.display = '';
 
                // enable/disable buttons
        document.getElementById('ButtonNext').name = 'step3';
        document.getElementById('ButtonNext').disabled = '';
 
        document.getElementById('ButtonPrevious').name = 'step1';
                document.getElementById('ButtonPrevious').disabled = '';
                
                document.getElementById('SubmitFinal').name = '';
                document.getElementById('SubmitFinal').disabled = 'disabled';
 
                // change navigation color
                document.getElementById('headstep3').style.backgroundColor = 'silver';
                document.getElementById('headstep2').style.backgroundColor = 'white';           
          }
        }
    </script>
    <style type="text/css">  
      #userregisterizard {
        width:500px;
        height: 350px;
        background-color:#EFEFEF;
        border-style:solid;
      border-width:5px;
      border-color:#001111;
      }
      #userregisterizard #wizardpanel{  
            padding: 5px;  
            height: 250;  
        }
        #userregisterizard #buttons{  
            padding: 5px;  
            height: 40;  
        }
        #navigationbar {
          padding: 2px; 
          height: 50px;
          background-color:silver;
        }  
    </style>
</head>
<body>
  <div id="userregisterizard">
    <div id="navigationbar">
      <label id="headstep1" style="background-color:white">Step 1: Register</label>  
      <label id="headstep2" style="background-color:silver">Step 2: Detail Profile</label>  
      <label id="headstep3" style="background-color:silver">Step 3: Finalize</label>
    </div>
    <div id="wizardpanel">
      <fieldset id="step1">
          <legend>Create User</legend>
        <label>Name<font color="red">*</font>: Enter your preferred user name</label><br>
        <input name="wsname" type="text"></br>
        <label>Password<font color="red">*</font>: Please use 8~16 characters that will protect your user account</label><br>
        <input name="uspassword" type="password"></br>
      </fieldset>
 
      <!-- edit yourself profile -->
      <fieldset id="step2" style="display:none">
        <legend>Edit Profile</legend>
        <label>Occupation<font color="red">*</font>: What do you do?</label><br>
        <input name="wsname" type="text"></br>
        <label>Company<font color="red">*</font>: Which company you are working for</label><br>
        <input name="company" type="text"></br>
        <label>Hometown<font color="red">*</font>: Where is you hometown</label><br>
        <input name="hometown" type="text"></br>
        <label>Mobilephone Number<font color="red">*</font>: Can we get your phone number?</label><br>
        <input name="phonenumber" type="text"></br>
      </fieldset>
      <fieldset id="step3" style="display:none">
          <legend>Welcome you</legend>
        <p>you can see the your user profile what you have entered.<p>
      </fieldset>
    </div>
    <div id="buttons">
      <input id="ButtonPrevious" type="button" value="Previous" disabled="disabled" name="" οnclick="handleWizardPre()"/>
      <input id="ButtonNext" type="button" value="Next" name="step2" οnclick="handleWizardNext()" />
      <input id="SubmitFinal" type="submit" value="Finish" disabled="disabled" />
    </div>
  </div>
</body>
</html>
相关文章
|
19天前
|
移动开发 前端开发 JavaScript
纯JavaScript实现HTML5 Canvas六种特效滤镜
纯JavaScript实现HTML5 Canvas六种特效滤镜
29 6
|
2天前
|
JavaScript 前端开发 API
探讨JavaScript动态添加HTML文件的技术
探讨JavaScript动态添加HTML文件的技术
9 1
|
3天前
|
XML 前端开发 JavaScript
HTML、CSS、JavaScript有什么区别
HTML、CSS、JavaScript有什么区别
|
12天前
|
XML 前端开发 JavaScript
前端简介(HTML+CSS+JS)
前端简介(HTML+CSS+JS)
|
15天前
|
数据库 数据安全/隐私保护 Python
Web实战丨基于django+html+css+js的电子商务网站
Web实战丨基于django+html+css+js的电子商务网站
36 3
|
15天前
|
前端开发 安全 数据安全/隐私保护
Web实战丨基于django+html+css+js的在线博客网站
Web实战丨基于django+html+css+js的在线博客网站
21 2
|
20天前
|
Web App开发 监控 JavaScript
JS 鼠标框选(页面选择)时返回对应的 HTML 或文案内容
JS 鼠标框选(页面选择)时返回对应的 HTML 或文案内容 当用户进行鼠标框选选择了页面上的内容时,把选择的内容进行上报。 分为以下几点: 选择文案时 选择图片、svg、iframe、video、audio 等标签时 选择 input、select、textarea 等标签时 选择 input、textarea 标签内容时 选择类似 &nbsp; 字符时 键盘全选时 鼠标右键选择 以上各模块结合时 当包含标签的时候,返回 html 结构,只有文本时返回文本内容
16 1
|
5天前
|
JavaScript 前端开发 算法
[练习]用Js获取html页面中表单提交的数据并且返回到控制台
[练习]用Js获取html页面中表单提交的数据并且返回到控制台
7 0
|
20天前
|
移动开发 前端开发 JavaScript
[初学者来练]用html+css+javascript个人博客作业需求
【6月更文挑战第3天】该项目旨在通过HTML、CSS和JavaScript创建一个响应式个人博客网站,提升前端开发技术理解与实践能力。主要包括设计简洁页面布局、实现主页展示、文章列表、详情页及评论功能。技术要求使用HTML5/CSS3/JavaScript,可选前端框架,强调代码质量和可维护性。提交内容需包括完整网站、开发文档和测试过的代码。评分标准涉及设计、功能实现、技术应用和文档质量。
20 0
|
1月前
|
移动开发 JavaScript 前端开发
webgl学习笔记3_javascript的HTML DOM
webgl学习笔记3_javascript的HTML DOM
28 0
webgl学习笔记3_javascript的HTML DOM