0
我已經在html中創建了一個表單,並且我想將其用戶插入的數據以JSON對象的形式存儲在JSON文件中&數組,我與json &一起使用JavaScript so friendly告訴我該怎麼做?將表單數據存儲到json文件中
這是我的HTML表單:
<!DOCTYPE html>
<html>
<body>
<form>
First name:<input type="text" name="firstname">Last name:<input type="text" name="lastname"><br>
Gender: <input type="radio" name="gender">male<input type="radio" name="gender">female<br>
Married: <input type="checkbox" name="married">yes<input type="checkbox" name="merried">no<br>
Degree:
<select>
<option>BS</option>
<option>MS</option>
<option>PhD</option>
</select>
Description: <textarea style="width:200px"></textarea>
</form>
</body>
</html>
,我想輸出以.json文件中像這樣:
[
{
"first name": "adam",
"last name": "smith"
"gender": "male",
"merried": "yes"
"degree": "MS",
"description": "any discription"
},
{
"first name": "anglina",
"last name": "jouley"
"gender": "female",
"merried": "no"
"degree": "PhD",
"description": "any discription"
},
]