0 Replies Latest reply on Oct 10, 2008 6:52 PM by (Jim_Colella)

    Need popup menu to fill fields

      I'm creating a form that will have multiple rows reactive to the selection of one field/button. I was planning to use the app.popUpMenu from a button, but all examples I'm finding so far show it triggering hyperlinks or documents. Can someone help me in getting this to populate a field? My fields are defined as follows:

      Row1.Item Row1.Bonus Row1.Dmg Row1.Rng
      Row2.
      Row3.

      I was planning to use:
      var cRowName = event.target.name.split(".").shift();

      That line came from the following sample I found on the internet:
      ////////////////
      // SetPartEntries()
      //
      // Function for setting the parts list based on the assmebly selection value
      //
      // This function is specifically setup to be called from the Change Event
      // of the Assembly List. It will not work from another event because the
      // "event.value" parameter is used
      //
      function SetPartEntries()
      {
      // Only run this code on when the selection is commited.
      if(event.willCommit)
      {
      // There are 3 rows in the order form so in order to use other fields in
      // the same row we first have to acquire the name of the row
      // we are operating on. This is part of the List field's name, so we
      // just have to split it off
      var cRowName = event.target.name.split(".").shift();

      // Now get the new parts list from the Master List
      // Since the selection is being committed, event.value contains the selection text
      var lst = oAssemblyParts[event.value];
      // If an entry is selected that we don't have a parts list for, then
      // the parts list is just cleared.
      if( (lst != null) && (lst.length > 0) )
      this.getField(cRowName + ".PartSelect").setItems(lst);
      else
      {
      this.getField(cRowName + ".PartSelect").clearItems();
      }

      // We have a new parts lists and the first entry is
      // is a non-selection. so clear the price field.
      this.getField(cRowName + ".Price").value = 0;
      }
      }

      This would allow me to apply to multiple rows if I read the source of this line correct. The values that would be applied will be text/numeric.

      This is the actual menu script I'm trying to get to fill fields.
      Below is a copy of a sample popup menu I found. How would I get this to apply values to the rows above from a master list/array? Really, all I'm looking to get help with now is how to get this to add values to a field.

      var aFruits = ["Fruits","Apples",["Oranges","navel","valencia"]];
      var aVeggies = ["Vegetables","Beans","Corn"];

      // Create an array to hold the top level menu entries
      var aTopItems = [aFruits, aVeggies];

      // Place Additional entry at end of the Top Level Item Array
      var aBerries = ["Berries","Huckle","Goose"];

      aTopItems.push(aBerries);
      var cRtn = app.popUpMenu.apply(app, aTopItems);

      if(cRtn != null)
      this.getField("Myfld").value = cRtn;

      The result would be oranges navel 12 fruit 3lbs.
      I was going to try and splice the two scripts together. Can I do that?

      Thanks in advance for any help,
      Jim