I have a few images and a form where I have an input text, one pair of radio button and a select option, everytime I select one radio button and one option both of them get disabled and it can't be select anymore until the 'guardar cambios' button is clicked, when I select an option (in the sample it is the option 1) and an one image it changes for another but what I want is to, in case the person select the wrong option, to undo that, so I create a function where it has three parameters the value of radio and select and the class of the image selected, i call it inside 'seleccionar' where I reset the values of those three elements, then I put it inside the click function (the undo button). https://codepen.io/luzsdx/pen/ExKqwXP
I followed this How to call a function from click event inside another click event function?
But the problem is that when I choose an image it doesnt get replace for another, can anybody tell me what I'm doing wrong? thank you and I get the 'classes is not defined' error in the console
function deshacer (classes, valorRadio, valorSelect) {
$(valorRadio).prop("selectedIndex", 0).attr('disabled', false);
$(valorSelect).val('none').attr('disabled', false)
$(`div.${classes}>object`).attr('data', 'diente.svg')
}
$('.deshacer').on('click', function(e){
e.preventDefault()
deshacer(classes, valorRadio, valorSelect)
})
function seleccionar(valorSelect, valorRadio, classes, idImg) {
if (valorSelect) {
if (confirm('¿Seleccionar pieza Nro ' + classes + '?')) {
} else {
return false
}
}
if (valorRadio == 'rojo') {
if (valorSelect == 2) {
alert('Extracción indicada es una prestación requerida.')
$('#tratSelect').val('none')
} else if (valorSelect == 1) {
$(`div.${classes}>img`).attr('src', 'https://cdn-0.emojis.wiki/emoji-pics/lg/red-circle-lg.png')
}
}
deshacer(classes, valorRadio, valorSelect)
}
<div class="body">something like<div class=body><div class="imagesRow"><!-- 1st Row -->....<!-- 2nd Row -->....</div></bodyThen, you can add new css class called active once images selected where you'll be able to check for active images. Please see this example [link] (stackoverflow.com/a/64341727/14435535)