나는 밀 <form>
HTML 파일 JS 에서 파일,다음 매개 변 이 양식을 하지만 오류를 밝혀:
Catch 되지 않는 형식 오류:읽을 수 없는 속성의 null(독서'매개 변').
나는 가정이기 때문에 이 JS 파일에 직접 연결되어 HTML 파일을 의미하는 JS 로드할 수 있습니다 전에 <form>
.
할 수 있는 사람이 말해주십시오를 해결하는 방법 이?
JS 코드는 아래:
// skip to the input fields
$start.addEventListener('click', function(){
$chooseStory.remove()
const inputs = []
inputs.push(`
<form id="form">
<label>Provide The Following Words</lable>
`)
// assign words of stories to names and placeholders of inputs
// the input will automatically loop for as many as the words are
for (const word of stories[$index.value].words) {
inputs.push(`
<input type="text" name='${word}' placeholder="${word}">
`)}
inputs.push(`
<button type="submit" id="submit"> Read Story </button>
<code id="result"></code>
</form>
`)
const inputsField = inputs.join('')
$container.innerHTML += inputsField
})
// retrieve value of the form
const $form = document.getElementById('form')
$form.addEventListener('submit', function(e){
e.preventDefault()
})