Drop down picklists on $$viewtemplates

I’m sure this is something that everyone already knows, but I’m posting it because it took a bit of looking up to find it (as bits were scattered everywhere) and I want the code in one place for next time.

Problem was that I wanted to be able to Navigate to a particular &RestrictToCategory via a drop-down on a $$ViewTemplate form.

You can’t create editable fields in the $$ViewTemplate so, you need to use HTML and Javascript.

Create a computed field with a name of CompanyListHTML

Add this function code to it…

NB: Important bits are DBLookup, and the FCL := bit which adds a “blank” entry to the top.


ServerName := @Name([CN]; @Subset(@DbName; 1));

ContactsDB := “contacts.nsf”;

ContactsCompanyList := “CompaniesView”;

FullCompanyList := @DbColumn( “” : “NoCache” ; ServerName : ContactsDB ; ContactsCompanyList ; 1 );

FCL := @Explode((“- Select a Company and click Show to view members -” + “:” + @Implode (FullCompanyList ; “:” ));“:”);

CP := “<option value="” + FCL + “">” + FCL + “”;

“[<select name="CompanyList">” + @Implode(CP; " ") +

“]”


Now create a button.

Set the Web Javascript on the button to…

var companyname = document.forms[0].CompanyList;

window.location.href(“XCompanyName?OpenView&Count=300&Login&RestrictToCategory=” + companyname.value);

Where XCompanyName is the view name, and companylist is the name of the dropdown box (in the function code).

This code could be changed to do lots of other things and I hope someone can benefit from it.

Subject: Drop down picklists on $$viewtemplates (missing code)

Damn… I forgot that my code would be translated…

The last line should read as follows (but replace the {} with

“{<select name="CompanyList">” + @Implode(CP; " ") +

“}”