如何将表单中的用户输入保存到JavaScript对象中(How to save user input from a form into JavaScript objects)

系统教程 行业动态 更新时间:2024-06-14 16:59:46
如何将表单中的用户输入保存到JavaScript对象中(How to save user input from a form into JavaScript objects)

我是Javascript的新手,我在创建一个功能时遇到了一些问题。 我有一个html表单,其中包含用户名和地址。

我想创建一个函数,当用户提交表单时,用户信息被保存到JavaScript对象中。

像这样的东西:

Var person = { Name : abc, Address: xyz}

我能够将信息保存到对象中,但是当新人提交表单时,旧信息将被覆盖。 是否可以为提交表单的每个用户创建单独的对象。

感谢您的帮助。

I'm new to Javascript and I'm having some issues creating a feature. I have an html form which takes in users name and address.

I want to create a function that when the user submits the form that users information is saved into a JavaScript object.

Something like this:

Var person = { Name : abc, Address: xyz}

I was able to save the information into an object but when ever a new person submits the form the old info is overwritten. Is it possible to create a separate object for every user who submits he form.

Thank you for the help in advance.

最满意答案

var a = []; // On some event a.push({ Name: newValue, Address: newValue }); var a = []; // On some event a.push({ Name: newValue, Address: newValue });

更多推荐

form,创建,对象,电脑培训,计算机培训,IT培训"/> <meta name="description"

本文发布于:2023-04-17 08:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/eb07e420e8b316e2e20a69b5c348fc19.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   如何将   象中   用户   form

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!