kdiamond
Member
Could I please get a quick hand with this javascript? I have one id number that shows a field, the rest of the ID's hide the field. There are 6 total ID's.
Now I have the need for ID 1 OR 5 to show the field, and the rest will hide it. I am trying to use the || or syntax but when I do, the fields don't hid at all - they are showing and constant no matter what ID is selected.
var addState= document.getElementById('pet_profiles___state').getValue();
var element1= Fabrik.getBlock('form_10').formElements.get('pet_profiles___TABC');
var element2= Fabrik.getBlock('form_10').formElements.get('pet_profiles___TABC_Expire');
if (addState=='1'||addstate=='5')
{
element1.show();
element2.show();
}
else if (addState=='2'||addstate='3'||addstate='4'||addstate=='6')
{
element1.hide();
element2.hide();
}
Now I have the need for ID 1 OR 5 to show the field, and the rest will hide it. I am trying to use the || or syntax but when I do, the fields don't hid at all - they are showing and constant no matter what ID is selected.
var addState= document.getElementById('pet_profiles___state').getValue();
var element1= Fabrik.getBlock('form_10').formElements.get('pet_profiles___TABC');
var element2= Fabrik.getBlock('form_10').formElements.get('pet_profiles___TABC_Expire');
if (addState=='1'||addstate=='5')
{
element1.show();
element2.show();
}
else if (addState=='2'||addstate='3'||addstate='4'||addstate=='6')
{
element1.hide();
element2.hide();
}