• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1579
  • Last Modified:

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
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';
}

Open in new window

0
ccpjc
Asked:
ccpjc
  • 12
  • 10
  • 2
  • +2
1 Solution
 
WilyGuyCommented:
What are you doing ONLOAD? (are they hidden ONLOAD)?
0
 
ccpjcAuthor Commented:
onload they should be hidden
0
 
bmosoftwareCommented:
I find the more effective syntax is :

crmForm.all.new_benowner1_c.style.display = 'none';
crmForm.all.new_benowner1_d.style.display = 'none';
}
else
{
crmForm.all.new_benowner1_c.style.display = '';
crmForm.all.new_benowner1_d.style.display = '';
0
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
ccpjcAuthor Commented:
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
0
 
WilyGuyCommented:
Are they hidden initially? (the OnLoad event) (you said they should be)
0
 
ccpjcAuthor Commented:
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
0
 
WilyGuyCommented:
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?
0
 
ccpjcAuthor Commented:
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.SelectedText' is a null or not an object
0
 
WilyGuyCommented:
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?
0
 
WilyGuyCommented:
sorry re-read the question, got that

0
 
ccpjcAuthor Commented:
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
0
 
WilyGuyCommented:
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:
crmForm.all.new_benowner1.FireOnChange();
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 = "";
}

Open in new window

0
 
ccpjcAuthor Commented:
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
0
 
WilyGuyCommented:
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....
0
 
WilyGuyCommented:
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.
0
 
ccpjcAuthor Commented:
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.FireOnChange();
new_benowner1 ->
if (crmForm.new_benowner1.DataValue == false)
{
    crmForm.all.new_benpre1_c.style.visibility = "none";
    crmForm.all.new_benpre1_d.style.visibility = "none";
}
else
{
    crmForm.all.new_benpre1_c.style.visibility = "";
    crmForm.all.new_benpre1_d.style.visibility = "";
}
0
 
WilyGuyCommented:
what is new_benpre1_c and new_benpre1_d?

If you only have one field, there should just be the new_benpre1.style.visibility, or am I missing something?
0
 
WilyGuyCommented:
And I assume the onLoad-> is not within that script for the OnChange?
0
 
ccpjcAuthor Commented:
new_benowner1 is the radio button
new_benpre1 is the text box

the onLoad has crmForm.all.new_benowner1.FireOnChange();

while onChange has
if (crmForm.new_benowner1.DataValue == false)
{
    crmForm.all.new_benpre1_c.style.visibility = "none";
    crmForm.all.new_benpre1_d.style.visibility = "none";
}
else
{
    crmForm.all.new_benpre1_c.style.visibility = "";
    crmForm.all.new_benpre1_d.style.visibility = "";
}
0
 
WilyGuyCommented:
TRY

if (crmForm.new_benowner1.DataValue == false)
{
    crmForm.all.new_benpre1.style.visibility = "none";
}
else
{
    crmForm.all.new_benpre1.style.visibility = "";
}
             
0
 
ccpjcAuthor Commented:
i'm close to giving up
i took screen shots in a last ditch effort
crm.jpg
0
 
bmosoftwareCommented:
your problem if the first line of your onchange event.

if(crmForm.new_benowner1.DataValue == false),

you forgot the .all i.e you have crmForm.new_benowner instead of crmForm.all.new_benowner
0
 
ccpjcAuthor Commented:
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
0
 
WilyGuyCommented:
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.
0
 
bguss01Commented:
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.
0
 
t-joeCommented:
HI,
try to use
crmForm.all.new_benpre1.style.display = 'none';
to hide the field, and
crmForm.all.new_benpre1.style.display = 'inline'; //or maybe 'block'
to show it again.
Also please note that the radio button field might also have the null value you should check for this too.

In the form OnLoad, put the script to show/hide the script inside a function and attach it to the onClick event of the radiobutton. It's better to have all your script code in one place, plus if you put it in OnChange then it will not fire until after you tab out of the radiobutton.

crmForm.all.new_benowner1.onclick = function {
if (crmForm.new_benowner1.DataValue == false)
{
    crmForm.all.new_benpre1.style.display = 'none';}
else
{
    crmForm.all.new_benpre1.style.display = 'inline'; //or maybe 'block'
}
}

Open in new window

0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 12
  • 10
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now