简体   繁体   English

我需要在提交的同一页上打印以HTML表单输入的值

[英]I need to print the values entered in an HTML form on the same page on submit

hotmailI need the values entered into the form to print out on the screen when submit is pressed. hotmail我需要输入表单中的值才能在按下提交时在屏幕上打印出来。 How do I do the Javascript to do this. 我该怎么做Javascript来做到这一点。 I don't know where to start so please help! 我不知道从哪里开始,所以请帮忙!

Also does it look formatted correctly, I feel i am missing some things and that using tables to format was probably the wrong way of doing it. 它还看起来格式正确吗,我觉得我缺少了一些东西,并且使用表格进行格式化可能是错误的方法。

  <script type="text/javascript">
info = document.getElementById("personalInfo");
    info.innerHTML = "<strong>Peronal Info: </strong>" + "<br>" + "Name: " + 
                    document.feedback.fname.value +
                    " " +
                    document.feedback.lname.value +
                    "<br>" + "Email: " +
                    document.feedback.email.value;

info = document.getElementById("experienceSubmit");
    info.innerHTML = "<strong>Experience and Salary: </strong>" + "<br>" + "Years of experience: " + 
                    document.feedback.experience.value +
                    "<br>" + "Date of availability: " +
                    document.feedback.date.value +
                    "<br>" + "Compensation Chosen: " +
                    document.feedback.comp.value +
                    "<br>" + "Region Selected: " +
                    document.feedback.region.value;

info = document.getElementById("otherSubmit");
    info.innerHTML = "<strong>Other information: </strong>" + "<br>" + "# of References " + 
                    document.feedback.reference.value +
                    "<br>" + "Additional Comments: " +
                    document.feedback.comments.value; 
return false;
}
</script>
</head>
<body background="../Assignment 5/_images/abstract_color_background_picture_8016-wide.jpg" >
<form   name="feedback" method="post" onSubmit="return checkform()">
        <section  id="pinfo" class="inputArea">
        <fieldset>
            <table>
                <tr>
                    <td>Last Name: </td>
                    <td><input name="lname"
                               type="text"
                               autofocus
                               required
                               placeholder="lname"                               
                               size="25" />
                    </td>
                </tr>                   
                <tr>
                    <td>First Name: </td>
                    <td><input name="fname"
                               type="text"
                               size="25"
                               required
                               placeholder="fname" />
                    </td>
                </tr>
                <tr>
                    <td>Email: </td>
                    <td><input name="email"
                               type="email"
                               size="40"
                               required
                               placeholder="....@hotmail.com" />
                     </td>
                </tr>
                    <td>Gender: </td>
                    <td><select name="gender">
                            <option selected disabled style='display:none;'>
                            Gender</option>                         
                            <option value="Male">Male</option>
                            <option value="Female">Female</option>                      
                        </select>

                </td>
                </tr>
            </table>
            </fieldset>
</section>
<section id="experience">
            <fieldset>
            <table>
                <tr>
                    <td>
                    <label for="experience">Years of Experience: </label>
                    <input name="experience" type="number" />
                  </td>
              </tr>
              <tr>
                    <td>
                        <label for="date">Date</label>
                        <input name="date" type="date" />
                    </td>
              <tr>
                    <td>
                        <label for="comp">Compensation: </label><br>
                        <input name="comp" type="radio" id="Salary" value="Salary Selected">Salary &nbsp;
                        <input name="comp" type="radio" id="SalaryWB" value="Salary with bonus Selected">Salary with Bonus &nbsp;
                        <input name="comp" type="radio" id="Commission" value="Commission Selected">Commission &nbsp;
                    </td>
              </tr>
              <tr>
                <td>
                    <label for="region">Region: </label><br>
                    <input name="region" type="checkbox" id="East" value="East Selected">East &nbsp;
                    <input name="region" type="checkbox" id="West" value="West Selected">West &nbsp;
                    <input name="region" type="checkbox" id="North" value="North Selected">North &nbsp;
                    <input name="region" type="checkbox" id="South" value="South Selected">South &nbsp;
                </td>
              </tr>
          </table>
          </fieldset>
</section>
<section id="other">
<fieldset>
          <table>
            <tr>
                <td>
                <label for="reference">References<br>0&nbsp;&nbsp 1 &nbsp;&nbsp 2 &nbsp&nbsp 3 &nbsp&nbsp 4 &nbsp&nbsp 5<br></label>
            <input name="reference" id="reference"
                    type="range" 
                    value="0"
                    min="0"
                    max="5"
                    step="1" />
                </td>
            </tr>
            <tr>
                <td>
                    <label for="comments">Additional Comments: <br></label>
                    <textarea 
                    name="comments"
                    rows="5" 
                    cols="20" 
                    placeholder="Please include any other pertinent information here"></textarea>                   </td>
            </tr>          
          </table>          
</fieldset>

        <input type="submit" value="Submit" />
        <input type="reset" value="Clear" />
</section>
</form>
<section id="personalInfo"></section>
<section id="experienceSubmit"></section>
<section id="otherSubmit"></section>
</body>

Yes in onsubmit checkform() function do the codding of printing values... 是的,在onsubmit checkform()函数中可以对打印值进行编码...

like... 喜欢...

<script>
    function checkform()
    {
         document.getElementById("outL").innerHTML=feedback.lname.value;
        //like this you can do for all field
    }
</script>

i have created sample for you. 我已经为您创建了示例。 please check below code 请检查下面的代码

$("#feedback").submit(function(e){
    alert("hi");
    event.preventDefault();
});

Link 链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 提交后如何在同一页中显示html表单值? - How to display html form values in same page after submit? 提交HTML表单以在新页面中显示输入的信息 - Submit HTML form to display entered info in new page 我需要使用Javascript将复选框中的值打印到HTML页面中 - I need to print the values from a checkbox to the page in HTML using Javascript 我需要一种表单,如果选中了表单中的复选框,然后将“提交”按钮打印页面,该表单会将一个类应用于div - I need a form that will apply a class to a div if a checkbox in form is checked then have submit button print the page 用户输入提交后,如何在同一页面中打印出表单字段值? - How to print out the form field values in the same page after the user enters submit? HTML提交表单,但留在同一页面上 - Html submit a form, but stay on the same page html 表格,提交并停留在页面的同一位置 - html form, submit and stay at same place on page 如何将在一个 html 页面表单上输入的值作为变量输入到另一个 html 页面上 - How do I take values entered on one html page's form, and enter them on another html page as variables 使用 javaScript 提交后,在同一页面的超链接内显示 html 表单值 - Display html form values inside hyperlink in same page after submit using javaScript 如何让表单将值提交到同一页面上的ng-repeat列表项? - How do I have a form submit values to an ng-repeat list item that's on the same page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM