Make a field Visible/invisible based upon another field

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
lyctysplt
User
Posts: 15

Make a field Visible/invisible based upon another field

Post by lyctysplt »

Can't seem to get the code working just right - I've tried a few things:

Custom attributes of the field:
"onchange='IsVirtualUpdate(this.value);'"

then in the startup scripts level:
function IsVirtualUpdate(selection) {

if (selection == 1){
	 $("#x_CPUCount").Visible = True; // Set value to field #2
	 $("#x_CoreCount").Visible = True; // Set value to field #2
	 $("#x_MemTotal").Visible = True; // Set value to field #2
} else {
	 $("#x_CPUCount").Visible = False; // Set value to field #2
	 $("#x_CoreCount").Visible = False; // Set value to field #2
	 $("#x_MemTotal").Visible = False; // Set value to field #2

}

);

Also did it this way - similar to the help file:
$("#x_IsVirtual").change(function() {
if (this.value == 1 ) {
$("#x_CPUCount").Visible = true; // Set value to field #2
$("#x_CoreCount").Visible = true; // Set value to field #2
$("#x_MemTotal").Visible = true; // Set value to field #2
} else {
$("#x_CPUCount").Visible = false; // Set value to field #2
$("#x_CoreCount").Visible = false; // Set value to field #2
$("#x_MemTotal").Visible = false; // Set value to field #2
}
});


motfs
User
Posts: 258

Post by motfs »

There is no .Visible in jQuery. Use jQuery .hide() method to hide (api.jquery.com/hide/ or .show() to show, see api.jquery.com/category/effects/basics/), e.g:

$("#x_CPUCount").hide(); // Hide this field
or
$("#x_CPUCount").show(); // Show this field


Post Reply