Commit aebc0b83 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

radio button reset

parent 3fbe99fd
......@@ -23,7 +23,7 @@ function Home() {
else if (!password) {
alert('비밀번호를 입력하세요')
}
else if (password !== '0319') {
else if (password !== '0000') {
alert('유효한 비밀번호를 입력하세요')
}
else {
......
import React, { useState } from 'react'
import { Link } from 'react-router-dom';
import Timer from 'react-compound-timer'; // 타이머쓰기위해 import
import logo from './img_question.png'
import logo from './img/img_question.png'
const QnA = [
{ Q: "6 X 4 = ?", Choose: [6, 12, 18, 24], A: "4", N: 1 },
......@@ -22,22 +20,21 @@ function Quiz() {
page: 0,
})
const [selected, setSelected] = useState("") //선택한 답을 보여줄 것들
// const [checked, setChecked] = useState(false)
function handleQuestion() {
setQuestion({ ...QnA[question.i + 1], i: question.i + 1, page: question.page + 1 })
// setChecked(false)
setSelected("")
}
let handleChange = (ev) => {
// ev.preventDefault() //새로고침 안되도록
setSelected(ev.target.value) //selected값 변경
Answers[question.N - 1] = Number(ev.target.id) + 1
localStorage.setItem('Answers', JSON.stringify(Answers))
}
}
return (
<div className="container-fluid position-absolute">
<div className="container-fluid">
<div className="text-center h2 font-weight-bold bg-warning py-2">미적분학 퀴즈</div>
<div className="row justify-content-md-center" >
<div className="col text-right">
......@@ -53,7 +50,7 @@ function Quiz() {
<form>
{question.Choose.map((a, index) =>
<div key={index}>
<input type="radio" name='answer' id={index} value={a} onClick={handleChange} />
<input type="radio" name='answer' id={index} value={a} onChange={handleChange} checked={parseInt(selected) === a} />
<label className="font-weight-bold" htmlFor={a}>{a}</label>
</div>
)}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment