Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Radio button in react

  const [gender,setgender]=useState()

 const handlegender=(e)=>{
    setgender(e.target.value)
  }
 

 
 <form>
        
        <div>
          <label>Gender</label>
          <input type="radio" name="gender" value="male" onChange={handlegender} />
          Male
          <input type="radio" name="gender" value="Female" onChange={handlegender}/>
          Female
        </div>
      </form>
Comment

how to use radio buttons in react class-based components

class App extends React.Component {
  
  setGender(event) {
    console.log(event.target.value);
  }
  
  render() {
    return ( 
      <div onChange={this.setGender.bind(this)}>
        <input type="radio" value="MALE" name="gender"/> Male
        <input type="radio" value="FEMALE" name="gender"/> Female
      </div>
     )
  }
}

ReactDOM.render(<App/>, document.getElementById('app'));
Comment

react input radio button


function App() {
  return (
    <div>
      <label className="radio">
  <input name="radio" type="radio" checked/>
  <span>Awesome</span>
</label>
<label className="radio">
  <input name="radio" type="radio" />
  <span>Cool</span>
</label>
    </div>
  );
}

export default App;
Comment

PREVIOUS NEXT
Code Example
Javascript :: ws.browser regeneratorRuntime is not defined angular 
Javascript :: reverse keys and values in object javascript 
Javascript :: get index in map javascript 
Javascript :: remove all sign that is not a-b in string js 
Javascript :: js push method 
Javascript :: GET http://localhost:8000/js/app.js net::ERR_ABORTED 404 (Not Found) in laravel 6 
Javascript :: from 0 or 1 to boolean javascript 
Javascript :: ordenar un array de menor a mayor 
Javascript :: how to watch for changes within a prop in vue 
Javascript :: async function syntax 
Javascript :: node mac copy to clipboard 
Javascript :: javascript check undefined 
Javascript :: convert json into map in java example 
Javascript :: how do i set an id for a div in js 
Javascript :: generate express app 
Javascript :: convert json to array 
Javascript :: gsheet query select remove header 
Javascript :: javascriot function 
Javascript :: local storage in vanila javascript 
Javascript :: js append to array 
Javascript :: javaScript setHours() Method 
Javascript :: Connect to socket.io node.js command line 
Javascript :: try catch async await 
Javascript :: Missing script: "start" react 
Javascript :: react detect page width 
Javascript :: model mongoose 
Javascript :: Download excel using reactJS 
Javascript :: javascript select element with two classes 
Javascript :: javascript convert input to lowercase 
Javascript :: js dom siblings 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =