Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/429.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript PHP-如何在插入数据库之前以多种形式显示用户输入_Javascript_Forms - Fatal编程技术网

Javascript PHP-如何在插入数据库之前以多种形式显示用户输入

Javascript PHP-如何在插入数据库之前以多种形式显示用户输入,javascript,forms,Javascript,Forms,我是PHP新手,我们有一个学校项目在线预约系统 我对如何在不单击提交按钮的情况下显示步骤3中的用户输入有疑问 单击“上一步”按钮并更新详细信息时,如何显示步骤3中更新的内容 步骤3是插入数据库之前的最后一步 任何帮助都将不胜感激。多谢各位 下面是源代码 * { 框大小:边框框; } 身体{ 背景色:#f1f1; } #正则表达式{ 背景色:#ffffff; 保证金:自动; 字体系列:雷威; 填充:40px; 宽度:70%; 最小宽度:300px; 边框:3px实心#f1f1; } h1{ 文

我是PHP新手,我们有一个学校项目在线预约系统

  • 我对如何在不单击提交按钮的情况下显示步骤3中的用户输入有疑问

  • 单击“上一步”按钮并更新详细信息时,如何显示步骤3中更新的内容

  • 步骤3是插入数据库之前的最后一步

    任何帮助都将不胜感激。多谢各位

    下面是源代码

    
    * {
    框大小:边框框;
    }
    身体{
    背景色:#f1f1;
    }
    #正则表达式{
    背景色:#ffffff;
    保证金:自动;
    字体系列:雷威;
    填充:40px;
    宽度:70%;
    最小宽度:300px;
    边框:3px实心#f1f1;
    }
    h1{
    文本对齐:居中;
    }
    输入{
    填充:10px;
    宽度:100%;
    字号:17px;
    字体系列:雷威;
    边框:1px实心#AAAAA;
    }
    挑选{
    填充:10px;
    宽度:100%;
    字号:17px;
    字体系列:雷威;
    边框:1px实心#AAAAA;
    }
    /*标记在验证时出错的输入框:*/
    输入无效{
    背景色:#ffdddd;
    }
    /*默认情况下隐藏所有步骤:*/
    .标签{
    显示:无;
    }
    钮扣{
    背景色:#2ea3f2;
    颜色:#ffffff;
    边界:无;
    填充:10px 20px;
    字号:17px;
    字体系列:雷威;
    光标:指针;
    边缘顶部:15px;
    }
    按钮:悬停{
    不透明度:0.8;
    }
    #prevBtn{
    背景色:#bbbbbb;
    }
    /*制作圆圈,指示表格的步骤:*/
    .步骤{
    高度:15px;
    宽度:15px;
    边际:0.2px;
    背景色:#2ea3f2;
    边界:无;
    边界半径:50%;
    显示:内联块;
    不透明度:0.5;
    }
    .step.active{
    不透明度:1;
    }
    /*标记已完成且有效的步骤:*/
    .一步完成{
    背景色:#4CAF50;
    }
    人力资源{
    宽度:100%;
    左边距:自动;
    右边距:自动;
    高度:3倍;
    背景色:#2ea3f2;
    颜色:#2ea3f2;
    }
    预约
    预约详情
    
    原因

    医生 艾玛·布莱德博士 约翰·华生 亚历山德拉·史密斯博士

    日历 个人信息
    名字

    姓氏

    性别

    电子邮件

    电话

    确认预约
    预订详情
    原因:

    医生:

    日期:

    个人信息
    名字:

    姓氏:

    性别:

    电子邮件:

    电话:

    以前的 提交 var currentTab=0;//当前选项卡设置为第一个选项卡(0) 显示选项卡(当前选项卡);//显示crurrent选项卡 功能显示选项卡(n){ //此函数将显示表单的指定选项卡。。。 var x=document.getElementsByClassName(“选项卡”); x[n].style.display=“块”; //…并修复上一个/下一个按钮: 如果(n==0){ document.getElementById(“prevBtn”).style.display=“无”; }否则{ document.getElementById(“prevBtn”).style.display=“inline”; } 如果(n==(x.length-1)){ document.getElementById(“nextBtn”).innerHTML=“提交”; }否则{ document.getElementById(“nextBtn”).innerHTML=“Next”; } //…并运行一个功能,该功能将显示正确的步进指示器: 固定步进指示器(n) } 函数nextPrev(n){ //此函数将确定要显示的选项卡 var x=document.getElementsByClassName(“选项卡”); //如果当前选项卡中的任何字段无效,请退出该功能: 如果(n==1&&!validateForm())返回false; //隐藏当前选项卡: x[currentTab].style.display=“无”; //将当前选项卡增加或减少1: currentTab=currentTab+n; //如果您已到达表单的末尾。。。 如果(currentTab>=x.length){ //…表格将在以下时间提交: document.getElementById(“regForm”).submit(); 返回false; } //否则,显示正确的选项卡: 显示选项卡(当前选项卡); } 函数validateForm(){ //此函数用于验证表单字段 变量x,y,i,valid=true; x=document.getElementsByClassName(“选项卡”); y=x[currentTab].getElementsByTagName(“输入”); //检查当前选项卡中每个输入字段的循环: 对于(i=0;i
    您好,请检查下面的代码,它对我有效

    <!DOCTYPE html>
    <html>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
    <style>
    * {
     box-sizing: border-box;
    }
    
    body {
     background-color: #f1f1f1;
    }
    
    #regForm {
     background-color: #ffffff;
     margin: auto;
     font-family: Raleway;
     padding: 40px;
     width: 70%;
     min-width: 300px;
     border: 3px solid #f1f1f1;
    }
    
    h1 {
     text-align: center; 
    }
    
    input {
     padding: 10px;
     width: 100%;
     font-size: 17px;
     font-family: Raleway;
     border: 1px solid #aaaaaa;
    }
    
    select {
     padding: 10px;
     width: 100%;
     font-size: 17px;
     font-family: Raleway;
     border: 1px solid #aaaaaa;
    }
    
    /* Mark input boxes that gets an error on validation: */
    input.invalid {
     background-color: #ffdddd;
    }
    
    /* Hide all steps by default: */
    .tab {
     display: none;
    }
    
    button {
     background-color: #2ea3f2;
     color: #ffffff;
     border: none;
     padding: 10px 20px;
     font-size: 17px;
     font-family: Raleway;
     cursor: pointer;
     margin-top: 15px;
    }
    
    button:hover {
     opacity: 0.8;
    }
    
    
    
    
    #prevBtn {
     background-color: #bbbbbb;
    }
    
    /* Make circles that indicate the steps of the form: */
    .step {
     height: 15px;
     width: 15px;
     margin: 0 2px;
     background-color: #2ea3f2;
     border: none; 
     border-radius: 50%;
     display: inline-block;
     opacity: 0.5;
    }
    
    .step.active {
     opacity: 1;
    }
    
    /* Mark the steps that are finished and valid: */
    .step.finish {
     background-color: #4CAF50;
    }
    
    hr {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    height: 3px;
    background-color:#2ea3f2;
    color:#2ea3f2;
    }
    
    
    </style>
    <body>
    
    <form id="regForm" action="insert.php" method="POST">
     <h1>Book for Appointment</h1>
     <div style="text-align:center;margin-top:40px;">
     <span class="step"></span>
     <span class="step"></span>
     <span class="step"></span>
    
     </div>
     <!-- One "tab" for each step in the form: -->
     <div class="tab"><h3>Appointment Details</h3>
     <hr>
     <p><strong>Reason</strong>
     <input placeholder="Reason..." oninput="this.className = ''" name="reason" id="reason" onblur="getVal(this.id)"></p>
      <p><strong>Doctor</strong>
     <select name="doctor" id="doctor" onchange="getVal(this.id)">
        <option value="Dr. Emma Blade">Dr. Emma Blade</option>
        <option value="Dr. John Watson">Dr. John Watson</option>
        <option value="Dr. Alexandra Smit">Dr. Alexandra Smith</option>
    
      </select>
     <br>
      <br>
     <label for="bday"><strong>Calendar</strong></label>
     <input type="date" id="date" name="bookingdate" id="date" onblur="getVal(this.id)">
    
     </div>
     <div class="tab"><h3>Personal Information</h3>
     <hr>
     <p><strong>First Name</strong><input id="fname" onblur="getVal(this.id)" placeholder="First name..." oninput="this.className = ''" name="fname"></p>
     <p><strong>Last Name</strong><input id="lname" onblur="getVal(this.id)" placeholder="Last name..." oninput="this.className = ''" name="lname"></p>
     <p><strong>Gender</strong><input id="gender" onblur="getVal(this.id)" placeholder="Gender..." oninput="this.className = ''" name="gender"></p>
     <p><strong>Email</strong><input id="email" onblur="getVal(this.id)" placeholder="E-mail..." oninput="this.className = ''" name="email"></p>
     <p><strong>Phone</strong><input id="phone" onblur="getVal(this.id)" placeholder="Phone..." oninput="this.className = ''" name="phone"></p>
     </div>
     <div class="tab"><h3>Confirm Appointment</h3>
     <hr>
    <h3>Booking Details</h3>
    <hr>
      <p><strong>Reason:</strong> </p><span id="id_reason"></span>
      <p><strong>Doctor:</strong> </p><span id="id_doctor"></span>
      <p><strong>Date: </strong></p><span id="id_date"></span>
    
    <h3>Personal Information</h3>
    <hr>
    
      <p><strong>First Name: </strong></p><span id="id_fname"></span>
      <p><strong>Last Name: </strong></p><span id="id_lname"></span>
      <p><strong>Gender: </strong></p><span id="id_gender"></span>
      <p><strong>Email: </strong></p><span id="id_email"></span>
      <p><strong>Phone: </strong></p><span id="id_phone"></span>
    
    
     </div>
     <div style="overflow:au to;">
     <div style="float:right;">
     <button type="button" id="prevBtn" onclick="nextPrev(-1)">Previous</button>
     <button type="button" id="nextBtn" onclick="nextPrev(1)">Submit</button>
     </div>
     </div>
     <!-- Circles which indicates the steps of the form: -->
    
    </form>
    
    <script>
    
    //Get Value of input box.
    function getVal(idInput){
      //alert();
      var valueOfInput = document.getElementById(idInput).value;
      document.getElementById("id_"+idInput).innerHTML = valueOfInput;
    }
    
    var currentTab = 0; // Current tab is set to be the first tab (0)
    showTab(currentTab); // Display the crurrent tab
    
    function showTab(n) {
     // This function will display the specified tab of the form...
     var x = document.getElementsByClassName("tab");
     x[n].style.display = "block";
     //... and fix the Previous/Next buttons:
     if (n == 0) {
     document.getElementById("prevBtn").style.display = "none";
     } else {
     document.getElementById("prevBtn").style.display = "inline";
     }
     if (n == (x.length - 1)) {
     document.getElementById("nextBtn").innerHTML = "Submit";
     } else {
     document.getElementById("nextBtn").innerHTML = "Next";
     }
     //... and run a function that will display the correct step indicator:
     fixStepIndicator(n)
    }
    
    function nextPrev(n) {
     // This function will figure out which tab to display
     var x = document.getElementsByClassName("tab");
     // Exit the function if any field in the current tab is invalid:
     if (n == 1 && !validateForm()) return false;
     // Hide the current tab:
     x[currentTab].style.display = "none";
     // Increase or decrease the current tab by 1:
     currentTab = currentTab + n;
     // if you have reached the end of the form...
     if (currentTab >= x.length) {
     // ... the form gets submitted:
     document.getElementById("regForm").submit();
     return false;
     }
     // Otherwise, display the correct tab:
     showTab(currentTab);
    }
    
    function validateForm() {
     // This function deals with validation of the form fields
     var x, y, i, valid = true;
     x = document.getElementsByClassName("tab");
     y = x[currentTab].getElementsByTagName("input");
     // A loop that checks every input field in the current tab:
     for (i = 0; i < y.length; i++) {
     // If a field is empty...
     if (y[i].value == "") {
     // add an "invalid" class to the field:
     y[i].className += " invalid";
     // and set the current valid status to false
     valid = false;
     }
     }
     // If the valid status is true, mark the step as finished and valid:
     if (valid) {
     document.getElementsByClassName("step")[currentTab].className += " finish";
     }
     return valid; // return the valid status
    }
    
    function fixStepIndicator(n) {
     // This function removes the "active" class of all steps...
     var i, x = document.getElementsByClassName("step");
     for (i = 0; i < x.length; i++) {
     x[i].className = x[i].className.replace(" active", "");
     }
     //... and adds the "active" class on the current step:
     x[n].className += " active";
    }
    </script>
    
    </body>
    </html>
    
    
    * {
    框大小:边框框;
    }
    身体{
    背景色:#f1f1;
    }
    #正则表达式{
    背景色:#ffffff;
    保证金:自动;
    字体系列:雷威;
    填充:40px;
    宽度:70%;
    最小宽度:300px;
    边框:3px实心#f1f1;
    }
    h1{
    文本对齐:居中;
    }
    输入{
    填充:10px;
    宽度:100%;
    字号:17px;
    字体系列:雷威;
    边框:1px实心#AAAAA;
    }
    挑选{
    填充:10px;
    宽度:100%;
    字号:17px;
    字体系列:雷威;
    边框:1px实心#AAAAA;
    }
    /*标记在验证时出错的输入框:*/
    输入无效{
    背景色:#ffdddd;
    }
    /*默认情况下隐藏所有步骤:*/
    .标签{
    显示:无;
    }
    钮扣{
    背景色:#2ea3f2;
    颜色:#ffffff;
    边界:无;
    填充:10px 20px;
    字号:17px;
    字体系列:雷威;
    光标:指针;
    边缘顶部:15px;
    }
    按钮:悬停{
    不透明度:0.8;
    }
    #prevBtn{
    背景色:#bbbbbb;