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 :: how to pass custom regex in jquery validation 
Javascript :: disable input box javascript 
Javascript :: input events 
Javascript :: create new connection in mongoose 
Javascript :: js add item to array 
Javascript :: javascript equivalent of CTRL+F5 
Javascript :: python convert json to csv 
Javascript :: toggle text on click in angular 
Javascript :: odd even javascript 
Javascript :: async function in javascript 
Javascript :: link to website electron 
Javascript :: javascript remove object from array 
Javascript :: hex string to decimal string javascript 
Javascript :: html to pdf nodejs 
Javascript :: comment in javascript 
Javascript :: js select keys from object 
Javascript :: how to get first element of an array in javascript 
Javascript :: useeffect cleanup in reactjs 
Javascript :: Material-ui add circle outline icon 
Javascript :: datepicker min max date 
Javascript :: set cors for a react node application socket error 
Javascript :: javascript loop over three-dimensional array 
Javascript :: try...catch...throw javascript 
Javascript :: js entries 
Javascript :: prependchild javascript 
Javascript :: javascript button click event 
Javascript :: javascript closure 
Javascript :: upi id regex 
Javascript :: js remove all except numbers 
Javascript :: Adding a Method to a JavaScript Object 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =