Want to get all selected check box values in one array. But onChange function is giving error as undefined.
I need checkedValue =[]`
And my : imgUrls = [ "https://dummyimage.com/100x100/bc6666/FFFFFF/&text=img-3","https://dummyimage.com/100x100/bc6666/FFFFFF/&text=img-4","https://dummyimage.com/100x100/bc6666/FFFFFF/&text=img-5","https://dummyimage.com/100x100/bc6666/FFFFFF/&text=img-6"]
var checkedValue =["https://dummyimage.com/100x100/bc6666/FFFFFF/&text=img-4","https://dummyimage.com/100x100/bc6666/FFFFFF/&text=img-5"]`
var imgUrls = [ "https://dummyimage.com/100x100/bc6666/FFFFFF/&text=img-3","https://dummyimage.com/100x100/bc6666/FFFFFF/&text=img-4","https://dummyimage.com/100x100/bc6666/FFFFFF/&text=img-5","https://dummyimage.com/100x100/bc6666/FFFFFF/&text=img-6"]
<ul>
{this.state.imgUrls.map(function (name, index) {
return <li key={index}>
input type="checkbox" id={name} name={name} onClick={this.funValue}/><label htmlFor={name}>
<img alt={name} src={name} value={name} />
</label>
</li>
})}
</ul>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.26/angular.min.js"></script>
Aucun commentaire:
Enregistrer un commentaire