问题同题。请帮助我,代码就在下面。我想保存来自文本框、 radio 、年龄的所有数据,并将其显示在其他地方,就好像它是一个注册页面一样。有什么想法吗?
HTML 部分:
<div id="nameC">Name:</div> <input type="text" maxlength="8" id="name" onkeypress="return ifnumberrr(event);" />
<div id="lnameC">Last Name:</div> <input type="text" maxlength="10" id="lname" onkeypress="return ifnumberrrr(event);" />
<div id="ageC">Age:</div> <input type="text" id="age" onkeypress="return ifnumber(event);" maxlength="2" />
<div id="genderT">Gender:</div>
<div class="genderM">Male
<input type="radio" id="gender" name="genderrr" />
</div>
<div class="genderF">Female
<input type="radio" id="gender" name="genderrr" />
</div>
<div id="button"><input type="submit" value="Submit" id="submit" /></div>
CSS部分:
<style>
.genderM {
position: fixed;
left: 175px;
top: 130px;
}
.rdGender {
position: absolute;
left: 175px;
}
#button {
position: absolute;
top: 200px;
left: 155px;
}
#genderT{
position:fixed;
top: 130px;
}
#nameC {
position:fixed;
top: 10px;
}
#lnameC{
position:fixed;
top: 50px;
}
#name{
position:fixed;
left: 175px;
top: 10px;
}
#lname{
position:fixed;
left: 175px;
top: 50px;
}
#ageC{
position:fixed;
top: 90px;
}
#age{
position:fixed;
left: 175px;
top: 90px;
}
.genderF{
position:fixed;
top: 130px;
left: 245px;
}
</style>
Javascript 部分:
<script language="javascript">
function ifnumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if(charCode > 31 && (charCode < 48 || charCode >57)) {
return false;
}
return true;
}
function ifnumberrr(e) {
var alphabet;
if (!e) var e = window.event;
if (e.keyCode) alphabet = e.keyCode;
else if (e.which) alphabet = e.which;
if ((alphabet >= 48) && (alphabet <= 57)) {
return false;
}
return true;
}
function ifnumberrrr(e) {
var alphabet;
if (!e) var e = window.event;
if (e.keyCode) alphabet = e.keyCode;
else if (e.which) alphabet = e.which;
if ((alphabet >= 48) && (alphabet <= 57)) {
return false;
}
return true;
}
</script>
最佳答案
你好@Altay Mazlum 要实现此目的,您可以使用 php 和 MySql。当您使用 php 提交表单时,它会创建值并使用插入方法将它们插入到 SQL 数据库中。
这样做之后,您还可以使用 php echo 函数调用这些值。
- 所以要遵循的步骤如下:
- 创建 SQL 数据库
- 使用 php 提交表单
- 在提交时将值插入到您的 sql 表中的行中
- 在通话中使用 php 检索数据并将其打印在页面上。
关于javascript - 我如何保存我的小注册页面中的所有数据并显示它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31160336/