JS code question - validation

Hi all,I have a DialogList field named “POType” with that should change the value of other DialogList type of fields when its value chjanges but the fields go blank instead of getting the value “-Not Applicable-”. Each of these fields has that value in its list. Can someone tell me how this can work?

Here is the onChange event code for the POType field:

field=“OrderType”;

nl=“\n”;

OrderTypeval=document.forms[0].elements[field].options[document.forms[0].elements[field].selectedIndex].text;

if (OrderTypeval==“Stock Order”){

vCustomer="-Not Applicable-";

vCustomerContact="-Not Applicable-";

vAccountManager="-Not Applicable-";

vProjectManager="-Not Applicable-";

vTechLead="-Not Applicable-";

document.forms[0].Customer.value=vCustomer;

document.forms[0].CustomerContact.value=vCustomerContact;

document.forms[0].AccountManager.value=vAccountManager;

document.forms[0].ProjectManager.value=vProjectManager;

document.forms[0].TechLead.value=vTechLead;

}  

var f = document.forms[0];

f.Customer.focus();

Thanks,

Dan

Subject: JS code question - validation

The general form for setting the value of a

Subject: RE: JS code question - validation

Hi Stan,I updated my code to reflect the exact position of the value for each field targeted:

field=“OrderType”;

nl=“\n”;

var doc = document.forms[0];

OrderTypeval=doc.elements[field].options[doc.elements[field].selectedIndex].text;

if (OrderTypeval==“Stock Order”){

vCustomer=doc.elements[Customer].options[1].selected;

vCustomerContact=doc.elements[CustomerContact].options[1].selected;

vAccountManager=doc.elements[AccountManager].options[1].selected;

vProjectManager=doc.elements[ProjectManager].options[1].selected;

vTechLead=doc.elements[TechLead].options[1].selected;

doc.Customer.value=vCustomer;

doc.CustomerContact.value=vCustomerContact;

doc.AccountManager.value=vAccountManager;

doc.ProjectManager.value=vProjectManager;

doc.TechLead.value=vTechLead;

}  

doc.Customer.focus();

I now get an error message (in IE7) as follows:

Error: ‘elements[…].options’ is null or not an object

Can you tell me how I can fix this so that it can work?

Thanks,

Dan