My task involves a set of buttons that behave in a specific way when clicked. By clicking on a button, the text "selected" is added to its existing value.
If one button is clicked, I want any other buttons with the text "selected" to have this text removed.
The desired functionality can be achieved by iterating through all the buttons within the specified area (all with the class of searchResult) and removing the text "selected" from each button if it is present.
Below is the code snippet for each button:
<input type="button" class="searchResult" onclick="$(\'#usersToSend > *\').css(\'background-color\', \'#fff\');
var oldValue = this.value;
this.value=\'(selected) \' + oldValue; this.style.backgroundColor = \'#51CA3E\';
document.getElementById(\'hiddenUserFlag\').value = \''.$row['id'].'\';"
value="'.$row['username'].'">
Pay attention to this part of the code:
$(\'#usersToSend > *\').css(\'background-color\', \'#fff\');
var oldValue = this.value;
this.value=\'(selected) \' + oldValue;
this.style.backgroundColor = \'#51CA3E\';