-
Notifications
You must be signed in to change notification settings - Fork 40
/
Multi Select dropdown checkbox in React js
61 lines (46 loc) · 1.63 KB
/
Multi Select dropdown checkbox in React js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React, { useState, useEffect } from 'react';
import { Container } from "react-bootstrap";
import Multiselect from 'multiselect-react-dropdown';
function Selectmultidropdown()
{
const [options, setOptions] =useState(['Option 1', 'Option 2','Test 3']);
const [country, setCountry]= useState([]);
useEffect(()=>{
const getcountrydata= async()=>{
const getcountryname=[];
const reqData= await fetch("http://localhost/devopsdeveloper/country");
const resData= await reqData.json();
//console.log(resData);
for(let i=0; i<resData.length; i++)
{
getcountryname.push(resData[i].nicename);
}
setCountry(getcountryname);
}
getcountrydata();
},[]);
return(<React.Fragment>
<Container className="content">
<div className="row">
<div className="col-sm-12">
<h3 className='mt-3'>Select Multi Dropdown Checkbox in React js</h3>
<form className="row g-3" method='post'>
<div className="col-md-5">
<label className="form-label"> </label>
<div className="text-dark">
<Multiselect
isObject={false}
onRemove={(event)=>{ console.log(event)} }
onSelect={ (event)=>{ console.log(event) }}
options={ country }
showCheckbox
/>
</div>
</div>
</form>
</div>
</div>
</Container>
</React.Fragment>);
}
export default Selectmultidropdown;