Reputation: 65
I am new to javascript any advice will be really much appreciated I am trying to hide my button and show it based in the value that been loaded to a field but my below code is not working
there is a field named ook if page loaded there will be a value display in ook it depends on the database but it will be loaded in page I want my button to hide if value is not yes
$(document).ready( function(){
var k = FormUtil.getField("ook").val();
if ( k ='YES') {
$("#btn).show();
} else { $("#btn).hide();
}
});
Upvotes: 0
Views: 195
Reputation: 2972
You had a typo in condition ( k ='YES')
, also in $("#btn)
selectors
$(document).ready( function(){
var k = FormUtil.getField("ook").val();
if ( k == 'YES') {
$("#btn").show();
} else {
$("#btn").hide();
}
});
Upvotes: 0
Reputation: 266
$(document).ready( function(){
$(function(){
var k = FormUtil.getField("ook").val();
if ( k ='YES')
{
$("#btn).css("display" ,"block")
} else { $("#btn).css("display ,"none")
}
});
});
Upvotes: 2