Automatically filling in fieldvalues on the web

Hi I have a form, that i’m designing for the web and the notes client. i have a field with a list of options. based on the oprion the user selects it should then automatically fill in another field with the manager of that option area. I’m using the following formula which works in the notes client:

@If(BusinessArea = “Area 1”; “Person One”; @If(BusinessArea = “Area 2”; “Person two”; @If(BusinessArea = “Area 3”; “Person three”; @If(BusinessArea = “Area 4”; “person four”; “”))))

however, when i fill in the form on the web it doesnt pull in the name of the manager, the field is not even visible.

What’s a good way of doing this so it works in both the notes and web client?

Subject: Automatically filling in fieldvalues on the web

Also, if the second field is display only, then this will not generate a handle in the web, Domino generates pure text and not a field. to get round this you can write HTMl to generate the dummy field or make the field editable and use the html attribute readonly=true ( IE only ).There are a number of other ways too, but just a pointer here

regards

Andy

Subject: RE: Automatically filling in fieldvalues on the web

Thanks a bunch for the tip Andy. One question though, is it ok to set the readonly attribute in the “HTML” tab of the properties value of the field?

Would i have to enclose the TRUE in quotes?

Thanks and regards again…

Subject: RE: Automatically filling in fieldvalues on the web

Not reliable – use the HTML Attributes object for the field and write it as a formula:

“readonly”

Subject: Automatically filling in fieldvalues on the web

in the onchange event of the list field, add some javascript to populate the second.

var f = document.forms[0];

var listfield = f.BusinessArea;

if ( listfield [listfield.selectedIndex].value == “Area 1” )

f.manager.value = “Person One”;

if ( listfield [listfield.selectedIndex].value == “Area 2” )

f.manager.value = “Person Two”;

also, your notes code : you do not need nested @ifs

this would be better

@If(

BusinessArea = “Area 1”;

“Person One”;

BusinessArea = “Area 2”;

“Person two”;

BusinessArea = “Area 3”;

“Person three”;

BusinessArea = “Area 4”;

“person four”;

“Unknown”

)

e.t.c

regards Andy

Subject: RE: Automatically filling in fieldvalues on the web

Andy i followed your example and it worked excellently in Notes except that on the Web the form shows up with the “unknown” value, but when i change the business are value, the “manager” value remains the same i.e - “unknown”.

Any suggestions?

Subject: Automatically filling in fieldvalues on the web

If you set the database to “Use JavaScript when generating pages” and set the BusinessArea field to “Refresh fields on keyword change”, the form will go back to the server to be recomputed. Oh, and that formula can be simplified to:

@If(BusinessArea = “Area 1”; “Person One”; BusinessArea = “Area 2”; “Person two”; BusinessArea = “Area 3”; “Person three”; BusinessArea = “Area 4”; “person four”; “”)

If you want to avoid the server-side refresh, you can use something like this in the onchange event of the BusinessArea field (this assumes that BusinessArea is a select – listbox, combobox or dialog list – field):

var personArray = split(‘Person One, Person Two, Person Three, Person Four’,', ');

var area = parseInt(this.options(this.selectedIndex).text.replace(/\D/g,‘’));

this.form.OtherFieldName.value = isNaN(area) ? ‘’ : personArray(area - 1);

That’s a bit tricky if you’re not into JavaScript (or another C-based language), but it’s just a compact way of saying:

“When this field has changed, create an array from this list of names. Then find out what has been selected and get the associated text. Replace everything in that text that isn’t a number with nothing. Try to convert that to a real number. Set the value of OtherFieldName to ‘’ if the conversion failed, otherwise subtract one from the number and give me the corresponding member from that array of names you made.”

Subject: I use a javascript popup window

I have something like this too. You select a project nbr and its get name, mgr, things like that. I use a javascript new window. On the new form, I use a dialog box with aliases so that I see the one value (Area 1) and it retrieves the other values too. Then, the button on the form parses the values and re-writes the values on the original form. You make the fields on the form editable, but use javascript onfocus event to move the cursor to the next field. So, if someone tries, they jump. If you need some sample code, email me at ddubos@virtualcon.com