Checkbox

if(document.forms[0].Hazards.value == “Biologicals”)document.forms[0].BLAH = “BH”;

in javascript

does not work. Can someone help me please

Subject: Checkbox on the web have “.checked” = true or false

With checkbox type fields, you need to check to see if the field is “checked” or not. When checked its value is returned to the server.

Is the field Hazards or BLAH checkbox type fields?

Take a look in your favorite JavaScript reference.

Subject: RE: Checkbox on the web have “.checked” = true or false

THe field Hazards is a checkbox type field. The field BLAH is a text box which is used to display corresponding values for the checkbox.

Subject: RE: Checkbox on the web have “.checked” = true or false

This is more inline with what you need to do:

if(document.forms[0].Hazards.checked)

document.forms[0].BLAH.value = “BH”;

if Hazards is a single field with multiple check box values, you’ll be dealing with an array and need to do something along these lines (looping for the value of x):

for (var x = 0; x < document.forms[0].Hazards.length; x++)

{

if(document.forms[0].Hazards.checked) {

document.forms[0].BLAH.value = document.forms[0].Hazards.value;

}

}

Subject: RE: Checkbox on the web have “.checked” = true or false

I used your code and it worked! The first time around. And now im getting the error document.forms[o].BLAH.value is null or not an object.

i dont understand