Hey @robertocook,
-- UPDATED -- I foolishly missed out the jQuery call on the element - OOPS! - writing this response in a rush earlier so, I apologise if you are unfamiliar with jQuery and it caused you any headaches!
PLEASE SEE UPDATED code below:
jQuery (or another JS library) is definitely how you would want to do this if it is on a form. Please see here:
www.j-cook.pro/forum/35-jquery/4481-show...ds-in-front-end-form
It's a demo on how to show/hide, disable input fields dependent on a radio button. You could easily adapt it to target the ID or CLASS of the dom element you want to manipulate.
Of course, if this is not in a form and/or the change of label that is required need not be interactive and instead, needs to change for each record returned where a certain
column (field) == true, then you need to override the JDom output.
Of course, you could equally stick with jQuery for this just like the forms. However, instead, you'd need to target the container of the text want and retrieve as opposed to the input fields' IDs/classes, then, set it's text property using the text() method;
//****** JS *********/
// init some vars
var myLabel = jQuery("#myFieldID.className");// change myFieldID & className to your bool field
var boolField.val() = jQuery("input[id='myYesNo']"); // change myYesNo to your bool field
// Check value of bool to set label
if(boolField == 0){ // or false... whatever your setup
// myLabel.text("Label if bool false"); --- UPDATED -- see next line //
jQuery(myLabel).text("Label if bool false");
}else{
// myLabel.text("Label if bool true"); --- UPDATED -- see next line //
jQuery(myLabel).text("Label if bool true");
}
You could easily wrap this in function, store it in a
[your_component].js file to include. Then you can call it anytime you like. Furthermore, adding a couple of parameters - bool and radio for instance - you could make it completely dynamic. Just pass them like
switchLabel("#radioID", "input[id='myYesNo']");
Anyway,
hope it helps!
Gez
Anyway,