JavaScript and Hidden Visibility Question

I have read a few posts on here on how to hide/show items with out refeshing the form which is what I need. I have a tabbed table and when I refesh the form goes to the first tab which is very annoying for my users.

Based on an earlier Posting I found, I created an

tag and a
closing tag and made each pass thru HTML.

On the field that I want to “refresh” when the value changes I added the following in the onChange event

el = document.getElementById(‘viewers’).style

if (txtWasDiscplineIssued == ‘No’) {

el.visibility = ‘hidden’

}else {

el.visibility = ‘visible’

}

I see that the rows of the table are hidden but when I click on the field to change the value I get a “Object Required” error. My field type is a Radio Button, Yes or No, with no default value.

What object am I missing and what can I do get this work correctly?

Subject: JavaScript and Hidden Visibility Question

Is txtWasDisciplineIssued a javascript var or one of the fields on your form? If it’s a field on your form the script should read as follows://assuming the first radio button option is yes

var f = document.forms[0];

if (f.txtWasDiscplineIssued[1].checked == true) {

el.visibility = ‘hidden’

}else {

el.visibility = ‘visible’

Subject: RE: JavaScript and Hidden Visibility Question

Thanks for your response, I appreciate your help.

Yes, txtWasDisciplinedIssued is the name of the Field. I changed the onChange event to an onClick event and am able to get it to work, how can I change the default to be null and change the values to be hidden and shown on Yes only?

Subject: RE: JavaScript and Hidden Visibility Question

The field is null by default unless you specify a value in the default section for your field. To make sure it’s null, place “” in the default value section for your field. To hide the field do the following.

//assuming the first radio button option is yes

var f = document.forms[0];

if (f.txtWasDiscplineIssued[0].checked != true) {

f.txtWasDiscplineIssued.type=“hidden”;

}else{f.txtWasDiscplineIssued.type=“visible”;}

Subject: RE: JavaScript and Hidden Visibility Question

I really really appreciate your help but I think I am getting more confused and am confusing two different processes.

I have a field called “FieldA” it is a radio button no default value, options are No or Yes.

Under that field I have “FIELDA1”, this field has the <DIV id=FA"> before and tag after it.

I want to hide the “FIELDA1” field if “FIELDA” is null or “No”. I only want to show it if they have “Yes” in “FIELDA”; basically, a if yes please explain field.

In the onClick event of the “FIELDA” I have tried what you have given me and it works if I have yes or no checked but initially it shows the “FIELDA1” field if the value is null? I do not, at least at this point, want to make “No” my default value but will if I need to or the DB Admin asks me to.

I have tried combining the two codes that you gave me using “else if” but was not able to hide the null value. I have several field on my form that I need to do this with so when I read on how to accomplish this some other users suggested the DIV tags. So I am not sure what my next step should be.

Subject: RE: JavaScript and Hidden Visibility Question

I’m not sure that I’m 100% clear on what you want, but let me offer this…

It sounds like you have the “onclick” portion working OK to hide/display FIELD1A when FIELDA is clicked.

But no matter what the value of FIELDA, the FIELDA1 will be visible when the form first loads unless you give it an initial display value. Maybe try something like this:

...

… where {COMPUTED TEXT} is something like:

@If(FIELDA=“Yes”;“visible”;“hidden”)

Basically just find a way to set the initial value without requiring the onclick event to fire.