I have my code below. I've made an empty array, but I don't know how to connect them. Also I tried to get the value from my combo box, but it's giving me an error. The textbox tho takes the value from the user's input but not the combo box.
function sample() {
var jsObject = [];
jsObject {
"salutation": null,
"fname": null
};
var sal = document.getElementById('salutation').value;
var fname = document.getElementById('fname').value;
if (fname.value == "") {
return false;
}
for (var key in sal) {
sal = sal[key];
}
}
<!DOCTYPE html>
<html>
<head>
<title>Sample</title>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<form name="sam" onsubmit="return sample()" method="post">
<select name="salutation">
<option value="mr">Mr.</option>
<option value="mrs">Mrs.</option>
<option value="dr">Dr.</option>
</select><br> Name:
<br>
<input type="text" name="fname" id="fname" required placeholder="Enter name">
<input type="submit" onclick="sample(); return false;" value="Submit">
</form>
</body>
</html>