简体   繁体   English

使用getElementById()提交后,如何在下一页上显示具有多种值类型的html表单?

[英]How to display html form with multiple type of values on next page after submit using getElementById()?

I was creating a form with multiple input type of data like date , number and text . 我正在创建具有多种input类型的数据(如datenumbertextform How do I display it on next page when I hit the submit button? 点击提交按钮后,如何在下一页显示它? I want to write a paragraph using these values. 我想用这些值写一个段落。 I was using JS. 我正在使用JS。

 <script type="text/javascript"> function generatesentence(){ var var1 = "In "; var var2 = document.getElementById('orgname'); var var3 = document.getElementById('postionnumber'); var var4 = "The city location is "; var var5 = document.getElementById('cityname'); var var6 = ". The last date of application is "; var var7 = document.getElementById('lasdat'); document.write(var1+var2.value+var3.value+var4+var5.value+var6+var7.value); } </script> 
 body{ background-image: url("ORGANIZATIONALRE-ORGANIZATIONOR.jpg"); } .organization-information{ width: 360px; padding:15% 0 0; margin: auto; } .form{ position: relative; z-index: 1; background: LightBlue ; max-width: 360px; margin: 0 auto 100px; padding: 45px; } .form input{ font-family: "roboto", sans-serif; outline: 1; background: #F5F5F5; width: 100%; border: 0; margin: 0 0 15px; box-sizing: border-box; font-size: 14px; } .form-button{ font-family: "roboto0",sans-serif; text-transform: uppercase; outline: 0; background: #4CAF50; width: 100%; border: 0; padding: 15px; color: inherit; font-size: 14px; } .concat{ position: relative; z-index: 1; background: LightBlue ; max-width: 360px; margin: 0 auto 100px; padding: 45px; } 
 <!doctype html> <html> <head> <title>Vacancies Available</title> <link rel="stylesheet" href="formstyle.css"> <script type="text/javascript" src="form.js"></script> </head> <body> <div class="organization-information"> <div class="form"> <form class="Org-info-form"> name of organization: <input type="text" name="Name" id="orgname" placeholder="enter the name here"/><br/> No of positions : <input type="number" name id="postionnumber" placeholder="Enter number of positions avaialble"/><br/> City Name : <input type="text" id="cityname" placeholder="Enter city name here"/><br/> Last Date for application : <input type="date" id="lasdat" placeholder="Last date of application"/><br/> <button onclick="generatesentence()">Submit</button> </form> </div> </div> </body> </html> 

There are various ways to access the input text of the input field. 有多种方法可以访问输入字段的输入文本。 I would suggest you to use 我建议你用

var2.innerText or var2.value var2.innerTextvar2.value

similar to every variable you are using 类似于您正在使用的每个变量

getElementById()

and I believe var3 will show an Error as getElementById() needs an argument. 而且我相信var3会显示错误,因为getElementById()需要一个参数。

Edit: here is a modified code 编辑:这是修改后的代码

function generatesentence(){
    var var1 = "In ";
    var var2 = document.getElementById('orgname');
    var var3 = (document.getElementById('postionnumber'));
    var var4 = "The city location is ";
    var var5 = document.getElementById('cityname');
    var var6 = ". The last date of application is ";
    var var7 = (document.getElementById('lasdat'));
    document.write(var1+var2.value+var3.value+var4+var5.value+var6+var7.value);
    }

暂无
暂无

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

相关问题 点击提交按钮后,如何将使用多种类型输入值创建的表格从表单显示到另一页? - How to display table created using multiple type input values from a form to another page after hitting submit button? 提交后如何在同一页中显示html表单值? - How to display html form values in same page after submit? 使用 javaScript 提交后,在同一页面的超链接内显示 html 表单值 - Display html form values inside hyperlink in same page after submit using javaScript 在不使用 PHP 的情况下单击表单中的提交(输入类型)后,如何使用 javascript 在页面上显示消息 - How to display a message on page using javascript after clicking on submit(input type) in a form without using PHP 单击带有getElementById的表单提交后,显示弹出窗口 - Getting popup to display after clicking a form submit with a getElementById 提交后,在另一个HTML页面上显示表单字段值 - Display form field value on another html page, after submit 使用Ghost.py提交表单后如何获取下一页 - How can i get next page after submit form using Ghost.py 如何在不使用数据库的情况下在html页面中单击提交按钮显示表单数据 - How to display form data onclick of submit button in html page without using Database 如何在 html 中提交表单后显示成功消息 - how to display success message after form submit in html 在表单提交时使用 javascript 捕获多个 HTML 元素值 - Capture multiple HTML element values using javascript on form submit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM