Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

set defaultValue for select element jsx

<div>
      <select
        value={choice}
        defaultValue={"default"}
        onChange={(e) => setChoice(e.target.value)}
      >
        <option value={"default"} disabled>
          Choose an option
        </option>
        <option value={"one"}>One</option>
        <option value={"two"}>Two</option>
        <option value={"three"}>Three</option>
      </select>
      <h1>You selected {choice}</h1>
</div>
Comment

select default value react

function TheSelectComponent(props){
     let currentValue = props.curentValue || "DEFAULT";
     return(
      <select value={currentValue} defaultValue={'DEFAULT'} onChange={props.onChange}>
        <option value="DEFAULT" disabled>Choose a salutation ...</option>
        <option value="1">Mr</option>
        <option value="2">Mrs</option>
        <option value="3">Ms</option>
        <option value="4">Miss</option>
        <option value="5">Dr</option>
      </select>
    )
}
Comment

how set default value for react-select

<select 
		defaultInputValue={this.props / this.state / ...}
or =>
		defaultInputValue="string"
/>
Comment

PREVIOUS NEXT
Code Example
Javascript :: _id to id 
Javascript :: javascript todataurl 
Javascript :: chrome.storage.local get 
Javascript :: dayjs now 
Javascript :: get all days of month javascript 
Javascript :: array filter 
Javascript :: var notification = new Notification 
Javascript :: javascript Get Key/Values of Map 
Javascript :: upload image react 
Javascript :: javascript tofixed is not a function 
Javascript :: how to add youtube videos to react app 
Javascript :: increased the value of a counter when a button is clicked in javascript 
Javascript :: javascript json deserialize 
Javascript :: jquery 1 cdn 
Javascript :: $q.platform.is.mobile 
Javascript :: how to enable click copy function using js 
Javascript :: array js fill 
Javascript :: fabric download 
Javascript :: preload 
Javascript :: javascript throw new error 
Javascript :: react native getstream 
Javascript :: generate express js project 
Javascript :: remove an element from array 
Javascript :: insert property multiple documents mongodb 
Javascript :: how to assert element attributes in cypress 
Javascript :: how to sort an array of object 
Javascript :: numbered occurences in regex 
Javascript :: functional component how to add to existing array react 
Javascript :: how to reade selected csv file data in node j s 
Javascript :: usereducer react js 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =