in my application react for exams i have 4 check box and beside every check box inputs and input of image
how i can make array of object every object contain checkbox and inputs which beside it
i need make relation bet them
const [data, setData] = useState([]);
const handleCheckboxChange = (index) => (event) => {
const newData = [...data];
newData[index] = {
...newData[index],
isCorrected: event.target.checked ? 1 : 0,
};
setData(newData);
};
const handleInputChange = (index) => (event) => {
const newData = [...data];
newData[index] = {
...newData[index],
name: event.target.value,
};
setData(newData);
};
<div className="mt-4" style={{ display: "flex", alignItems: "center" }} >
<div className='check' style={{ width: "20px", transform: "scale(2)", marginTop: "-18px" }}>
<input type="checkbox" name="adminIds" width={"100px"} />
</div>
<div className='camera_and_input '>
<input type="text" className="form-control" id="inputField" placeholder="Enter text" />
{/* <i className="fas fa-image fa-2x" aria-hidden="true" style={{direction:"ltr"}}></i> */}
<input type="file" id="imageInput" accept="image/*" style={{ direction: "ltr" }} />
</div>
</div>
</div>
<div className="wraper_input_and_checkbox">
<div className="mt-4" style={{ display: "flex", alignItems: "center" }} >
<div className='check' style={{ width: "20px", transform: "scale(2)", marginTop: "-18px" }}>
<input type="checkbox" name="adminIds" width={"100px"} />
</div>
<div className='camera_and_input '>
<input type="text" className="form-control" id="inputField" placeholder="Enter text" />
{/* <i className="fas fa-image fa-2x" aria-hidden="true" style={{direction:"ltr"}}></i> */}
<input type="file" id="imageInput" accept="image/*" style={{ direction: "ltr" }} />
</div>
</div>
</div>
<div className="wraper_input_and_checkbox">
<div className="mt-4" style={{ display: "flex", alignItems: "center" }} >
<div className='check' style={{ width: "20px", transform: "scale(2)", marginTop: "-18px" }}>
<input type="checkbox" name="adminIds" width={"100px"} />
</div>
<div className='camera_and_input '>
<input type="text" className="form-control" id="inputField" placeholder="Enter text" />
{/* <i className="fas fa-image fa-2x" aria-hidden="true" style={{direction:"ltr"}}></i> */}
<input type="file" id="imageInput" accept="image/*" style={{ direction: "ltr" }} />
</div>
</div>
</div>
<div className="wraper_input_and_checkbox">
{/* */}
tring puting it in array but not make relation am=nd not be in the same object
New contributor
Mostafa Esam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.