Answers for "get option value in react by usestate"

0

get option value in react by usestate

const [addrtype, setAddrType] = useState('Home')

function handleAddrTypeChange(e) {
    setAddrType(e.target.value);
    console.log(addrtype)
}


                            <select
                                defaultValue={addrtype}
                                onChange={handleAddrTypeChange}
                                className="browser-default custom-select">
                                <option selected value="1">Home</option>
                                <option value="2">Marketing</option>
                                <option value="3">Work</option>
                                <option value="3">Head Office</option>
                            </select>
Posted by: Guest on August-11-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language