ccpjc
asked on
Show and Hide fields in CRM
I have a text area that i need to be visible or hidden depending on a Yes or No from a radio button. But i can't seem to get it to work
I have listed the code I have in the onChange event for the text area
Any help would be appreciated.
Thanks
I have listed the code I have in the onChange event for the text area
Any help would be appreciated.
Thanks
var categorytype;
categorytype = crmForm.new_benowner1.SelectedText;
if (categorytype != 'No')
{
crmForm.all.new_benowner1_c.style.visibility = 'hidden';
crmForm.all.new_benowner1_d.style.visibility = 'hidden';
}
else
{
crmForm.all.new_benowner1_c.style.visibility = 'visible';
crmForm.all.new_benowner1_d.style.visibility = 'visible';
}
What are you doing ONLOAD? (are they hidden ONLOAD)?
ASKER
onload they should be hidden
I find the more effective syntax is :
crmForm.all.new_benowner1_ c.style.di splay = 'none';
crmForm.all.new_benowner1_ d.style.di splay = 'none';
}
else
{
crmForm.all.new_benowner1_ c.style.di splay = '';
crmForm.all.new_benowner1_ d.style.di splay = '';
crmForm.all.new_benowner1_
crmForm.all.new_benowner1_
}
else
{
crmForm.all.new_benowner1_
crmForm.all.new_benowner1_
ASKER
doesn't seem to work either
I don't know what else i need?
i have tried both methods in the onChange event.. I am using radio buttons that were set with with bit
I don't know what else i need?
i have tried both methods in the onChange event.. I am using radio buttons that were set with with bit
Are they hidden initially? (the OnLoad event) (you said they should be)
ASKER
they're supposed to be but they don't hide
does that code need to be in the onload? the previous admin for crm has scripts on the same page i'm working on but nothing in onload and they still work fine
does that code need to be in the onload? the previous admin for crm has scripts on the same page i'm working on but nothing in onload and they still work fine
Well, if they are supposed to be hidden by default when you open (or create), it should be in the onload first. Then you would UNHIDE them in the OnChange.
Does that make sense?
Does that make sense?
ASKER
Ok, well I'm not the best with Java, I don't really like it that much, is my syntax correct?
i also put the code into the onLoad event for the form and it's throwing me an error message now
There was an error with thie field's customized event.
Field: crmForm
Event: onLoad
Error: 'crmForm.new_benowner1.Sel ectedText' is a null or not an object
i also put the code into the onLoad event for the form and it's throwing me an error message now
There was an error with thie field's customized event.
Field: crmForm
Event: onLoad
Error: 'crmForm.new_benowner1.Sel
I need to look at the code again, but this time actually test it :)
So the what are you trying to hide? The Radio Button bit fields or is that what is being used to determine whether to show or hide the fields in question?
So the what are you trying to hide? The Radio Button bit fields or is that what is being used to determine whether to show or hide the fields in question?
sorry re-read the question, got that
ASKER
when the user clicks Yes on the radio button, it is supposed to show a field
if the radio button is no, the text field is hidden
if the radio button is no, the text field is hidden
OK, so lets take this a chunk at a time.
First the OnChange Event needs to be editted for the Radio Button field (you indicate you have it on the Text Area).
Second, See the Snippet for the code (keep in mind case sensitivity)
Third, for the OnLoad of the form, include:
Good Luck
First the OnChange Event needs to be editted for the Radio Button field (you indicate you have it on the Text Area).
Second, See the Snippet for the code (keep in mind case sensitivity)
Third, for the OnLoad of the form, include:
crmForm.all.new_benowner1. FireOnChan ge();
Lastly, you should make sure it defaults at the attribute level to "No"Good Luck
if (crmForm.new_benowner1.DataValue == false)
{
crmForm.all.new_benowner1_c.style.visibility = "none";
crmForm.all.new_benowner1_d.style.visibility = "none";
}
else
{
crmForm.all.new_benowner1_c.style.visibility = "";
crmForm.all.new_benowner1_d.style.visibility = "";
}
ASKER
thanks for the help, but all it does it throw error messages
field isn't hidden, if i hit yes or no on the radio button it shows the error messages as well
same ones listed as above
field isn't hidden, if i hit yes or no on the radio button it shows the error messages as well
same ones listed as above
Shouldn't be the exact same error....
So look in the attribute list and determine if the names are correct (case sensitive, etc.) and make sure the Radio Box has the correct default in its attribute form. I assume it was Yes/No....
So look in the attribute list and determine if the names are correct (case sensitive, etc.) and make sure the Radio Box has the correct default in its attribute form. I assume it was Yes/No....
Any luck....
The code snippet is what worked on my test system. Understand that I changed the attribute names to what you had. So benowner1 should be the Radio Button attribute (and as I mentioned this OnChange should be on the Radio Button, not the Text field). Then benowner1_c and _d are the fields you want to show up.
The code snippet is what worked on my test system. Understand that I changed the attribute names to what you had. So benowner1 should be the Radio Button attribute (and as I mentioned this OnChange should be on the Radio Button, not the Text field). Then benowner1_c and _d are the fields you want to show up.
ASKER
ok I'll try and sort this out, this is what I have and where
custom attribute 1 (new_benowner1)= Bit, with Yes and No, the default is No
custom attribute 2 (new_benpre1) = Navchar, listed as Text and limited to 4 characters in length
when the Bit = No, the Navchar should be hidden
I actually just noticed something, with the code listed above, if it worked properly it would hide itself, so i changed the bottom area to new_benpre1
on the form
onLoad -> crmForm.all.new_benowner1. FireOnChan ge();
new_benowner1 ->
if (crmForm.new_benowner1.Dat aValue == false)
{
crmForm.all.new_benpre1_c. style.visi bility = "none";
crmForm.all.new_benpre1_d. style.visi bility = "none";
}
else
{
crmForm.all.new_benpre1_c. style.visi bility = "";
crmForm.all.new_benpre1_d. style.visi bility = "";
}
custom attribute 1 (new_benowner1)= Bit, with Yes and No, the default is No
custom attribute 2 (new_benpre1) = Navchar, listed as Text and limited to 4 characters in length
when the Bit = No, the Navchar should be hidden
I actually just noticed something, with the code listed above, if it worked properly it would hide itself, so i changed the bottom area to new_benpre1
on the form
onLoad -> crmForm.all.new_benowner1.
new_benowner1 ->
if (crmForm.new_benowner1.Dat
{
crmForm.all.new_benpre1_c.
crmForm.all.new_benpre1_d.
}
else
{
crmForm.all.new_benpre1_c.
crmForm.all.new_benpre1_d.
}
what is new_benpre1_c and new_benpre1_d?
If you only have one field, there should just be the new_benpre1.style.visibili ty, or am I missing something?
If you only have one field, there should just be the new_benpre1.style.visibili
And I assume the onLoad-> is not within that script for the OnChange?
ASKER
new_benowner1 is the radio button
new_benpre1 is the text box
the onLoad has crmForm.all.new_benowner1. FireOnChan ge();
while onChange has
if (crmForm.new_benowner1.Dat aValue == false)
{
crmForm.all.new_benpre1_c. style.visi bility = "none";
crmForm.all.new_benpre1_d. style.visi bility = "none";
}
else
{
crmForm.all.new_benpre1_c. style.visi bility = "";
crmForm.all.new_benpre1_d. style.visi bility = "";
}
new_benpre1 is the text box
the onLoad has crmForm.all.new_benowner1.
while onChange has
if (crmForm.new_benowner1.Dat
{
crmForm.all.new_benpre1_c.
crmForm.all.new_benpre1_d.
}
else
{
crmForm.all.new_benpre1_c.
crmForm.all.new_benpre1_d.
}
TRY
if (crmForm.new_benowner1.Dat aValue == false)
{
crmForm.all.new_benpre1.st yle.visibi lity = "none";
}
else
{
crmForm.all.new_benpre1.st yle.visibi lity = "";
}
if (crmForm.new_benowner1.Dat
{
crmForm.all.new_benpre1.st
}
else
{
crmForm.all.new_benpre1.st
}
ASKER
your problem if the first line of your onchange event.
if(crmForm.new_benowner1.D ataValue == false),
you forgot the .all i.e you have crmForm.new_benowner instead of crmForm.all.new_benowner
if(crmForm.new_benowner1.D
you forgot the .all i.e you have crmForm.new_benowner instead of crmForm.all.new_benowner
ASKER
if i use the onload line i get an error
when i put in the .all it gets rid of an error message popping up when i hit yes, but if i go back to no the error message pops up
also the field doesn't hide
i don't get this
when i put in the .all it gets rid of an error message popping up when i hit yes, but if i go back to no the error message pops up
also the field doesn't hide
i don't get this
Can you open the Entity and show the attribute list with those entities?
Sounds like something simple like the attribute name isn't what you have there.
Beneficial Owner is the Radio Button, correct?
Can we see the attribute properties?
Don't give up.
Sounds like something simple like the attribute name isn't what you have there.
Beneficial Owner is the Radio Button, correct?
Can we see the attribute properties?
Don't give up.
I have skimmed through the posting but if it is working with the onload by changing the field name to crmForm.all.new_benowner and when you change the radio button, it is still erroring, is might be you did not update it on the onchange event.
Did you also make the change on the onchange event.
Did you also make the change on the onchange event.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.