javascript - 我如何保存我的小注册页面中的所有数据并显示它们

标签 javascript html css

问题同题。请帮助我,代码就在下面。我想保存来自文本框、 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/

相关文章:

javascript - 流/gulp注入(inject)问题

javascript - 将数据传递给 onclick 事件会取消字符串的大写

javascript - 具有 CSS 过渡效果的 jquery 悬停功能仅适用于第二次悬停

html - 用背景图像填充 SVG 路径元素

javascript - 从 a-z 中选择一个随机字母

javascript - NULL 与 MySQL、PHP、JSON 和 JavaScript

javascript - 无法使用 jQuery 打印表格网格

javascript - getElementsByTagName(a) 用于自动滚动

javascript - 添加外部脚本时不起作用

javascript - Material.io 标签 : where to put the tab content?