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 :: var in js 
Javascript :: array==null array.length java script 
Javascript :: autocannon npm 
Javascript :: javascript documentation 
Javascript :: Show and Hide Content jQuery 
Javascript :: process nexttick 
Javascript :: d3 force simulation 
Javascript :: jquery camera priview 
Javascript :: angular create injectable 
Javascript :: useLocation for query params 
Javascript :: datatable set data of column 
Javascript :: get all form errors angular 
Javascript :: how to make javascript function consise 
Javascript :: usestate hook callback 
Javascript :: call a function 
Javascript :: how to create a component in angular using terminal 
Javascript :: create multiple array buttons in javascript 
Javascript :: how to sepaarte text in object javascript 
Javascript :: find second smallest number in array 
Javascript :: gettwofactorauthenticationuserasync returns null 
Javascript :: javascript format time from number 
Javascript :: react using button props child 
Javascript :: react doc viewer 
Javascript :: angular hash sign in url 
Javascript :: Expo camera rotation 
Javascript :: return js 
Javascript :: convert svg to react component 
Javascript :: javascript create anchor link 
Javascript :: js user add names to a list on screen 
Javascript :: how to assign char in a string javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =