Show/Hide field based on lookup
Posted: 2019-04-17 18:48
Hi all,
I likely am way of with this but I am trying to show hide a field or two based on one value from a lookup field. I thought I would create a tablename-dv.js file with the following code in it. I have tried both text and a numerical value of the text selection. Neither works:
$j(document).ready(function(){
$j('#My_Field').change(function() {
if($j('#My_Field').text()=="This Value")
$j('#ScID').show();
else
$j('#ScID').hide();
})
})
I have used the code from Ahmed's tutorials but it does the opposite and hides the field when the lookup is selected:
$j(function(){
$j('#My_Field').on('change', function(){
var IR = parseFloat($j(this).val());
if(IR == 'This Value'){
$j('#ScID').parents('.form-group').show();
}else{
$j('#ScID').parents('.form-group').hide();
}
});
});
I am not sure what I have to do, I did try and use the value of the selection (7) as well.
I likely am way of with this but I am trying to show hide a field or two based on one value from a lookup field. I thought I would create a tablename-dv.js file with the following code in it. I have tried both text and a numerical value of the text selection. Neither works:
$j(document).ready(function(){
$j('#My_Field').change(function() {
if($j('#My_Field').text()=="This Value")
$j('#ScID').show();
else
$j('#ScID').hide();
})
})
I have used the code from Ahmed's tutorials but it does the opposite and hides the field when the lookup is selected:
$j(function(){
$j('#My_Field').on('change', function(){
var IR = parseFloat($j(this).val());
if(IR == 'This Value'){
$j('#ScID').parents('.form-group').show();
}else{
$j('#ScID').parents('.form-group').hide();
}
});
});
I am not sure what I have to do, I did try and use the value of the selection (7) as well.