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 :: find in array react 
Javascript :: how to sum two var in jquery 
Javascript :: jquery replace text in button 
Javascript :: cheerio load from file 
Javascript :: js date format mm/dd/yyyy 
Javascript :: web-vitals react 
Javascript :: javascript on image load 
Javascript :: flutter parse json 
Javascript :: allow cors express 
Javascript :: remove undefined from javascript array map 
Javascript :: remove a specific element from an array 
Javascript :: vue dynamic create watch 
Javascript :: How to install react native hooks with npm 
Javascript :: javascript get random items from array 
Javascript :: how to comment in the react javascript 
Javascript :: transitionduration javascript 
Javascript :: react native elevation 
Javascript :: refresh page on div click 
Javascript :: relode div 
Javascript :: materialize for react 
Javascript :: jquery json object 
Javascript :: add zero in front of numbers javascript 
Javascript :: create react app failed with code 1 
Javascript :: download text file javascript 
Javascript :: regex match everything except 
Javascript :: javascript remove characters from beginning of string 
Javascript :: javascript onclick image 
Javascript :: random int javascript 
Javascript :: install react native gifted charts 
Javascript :: how to get ip address javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =