我是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"
发布评论