Getting Error on ListBox

Sort:
You are not authorized to post a reply.
Page 2 of 2 << < 12
Author
Messages
Bill Alt
Advanced Member
Posts: 25
Advanced Member
    Got it. Thanks. I was wondering about what was different. So just to make sure, I will change


    to


    And then reference in the VALUES_onBlur
    if (id == "select1") {
    var empname = lawForm.getFormValue("select1");
    lawForm.setFormValue("hidden50",empname);
    Bill Alt
    Advanced Member
    Posts: 25
    Advanced Member
      OK, it left out my post that time.

      fld al="left" blankzero="1" col="42" ed="upper" height="1" id="text2" label="Level1 Approv" nbr="_f4" nm="ZZR-LEVEL1-APPROV" row="13" sz="15" tp="Text"

      will be

      fld al="left" blankzero="1" col="42" ed="upper" height="1" id="hidden50" label="Level1 Approv" nbr="_f4" nm="ZZR-LEVEL1-APPROV" row="13" sz="15" tp="Hidden"
      Randy Jacoy
      Veteran Member
      Posts: 46
      Veteran Member
        That looks good to me (assuming select1 is your list box).  Let me know if that does the trick.
        Bill Alt
        Advanced Member
        Posts: 25
        Advanced Member
          Will do. Appreciate all the help.
          Bill Alt
          Advanced Member
          Posts: 25
          Advanced Member
            OK. I lied. I am experiencing a couple of anomalies. I use the code that you first had given me to display the name. It works great in VALUES_OnBlur. I figured, why not populate the names on an inquire instead of a read to the database. It seems to work sometimes and others not. The values are there because they appear in the drop down list and once I select, the name appears. Any ideas on that?

            And as for the hidden fields, I can rename it and it still works for populating the database. It seems though once I make it hidden it stops working.

            And this one should be easy for you I am sure. I was changing the text boxes to read only depending on the user. Worked fine for text boxes. Not so much it looks like for select boxes.
            lawForm.getFormElement("text5").readOnly=true; works
            lawForm.getFormElement("select5").readOnly=true; doesn't work

            Thanks again.
            Randy Jacoy
            Veteran Member
            Posts: 46
            Veteran Member

              Are you populating names in the FORM_OnAfterTransaction function?  You'll find that even though the list box shows a value, it's not actually "selected".  So what you need to do is set the select form field to the value of the data that came back in the transaction and then call the routine to get the display value for the selected value.  For example, here is what I did for state:

               //Select the state in the state list box.
               lawForm.setFormValue("select35",lawForm.getDataValue("VDR-STATE"));

               // Put the state name in the textbox next to the state.
               lawForm.setFormValue("text85",getSelectedListboxValue("_l623"));

              Incidentally, I placed the getSelectedListboxValue in a global functions include file so I can just call it with one line rather than coding that loop everywhere.  Here is the function:

              function getSelectedListboxValue(lb) {
               
               /* This function returns the display value of the selected item in a listbox.
                Example call: var myselectedvalue = getSelectedListboxValue("_l623"); */
               var myDisplayValue = ''; // This is the value that will be returned to the caller.
               var myListbox = lawForm.getElement(lb); // This gets a reference to the list box.
               
               // Loop through all the items in the list box until we find the one that was selected.
               for (var i=1; i < myListbox.childNodes.length; i++) {
                if (myListbox.childNodes.selected == true) { // Test to see if the item is selected.
                 myDisplayValue = myListbox.childNodes.attributes['disp'].nodeValue; // Get the display value of the selected item.
                 break; //This breaks out of the for loop.  No need to continue checking items after we've found the selected item.
                }
               }

               return myDisplayValue;
               
              }

              Regarding your hidden field not working, it's difficult to determine the issue without actually having your full program.  In my case I didn't even change the field name; I just added tp="Hidden" to the field.  Below is what I did for the state field.  Make sure the "nbr" and "nm" match the Infor generated values for those fields.

                fld al="left" blankzero="1" col="42" ed="upper" height="1" id="text11" label="State or Province:" nbr="_f29" nm="VDR-STATE-PROV" par="TF0-0" row="8" sz="2" tp="Hidden"/

              Regarding the read only attribute, listboxes don't have that property.  Try lawForm.getElement("_l183").disabled=true; (use your field ID).

              Bill Alt
              Advanced Member
              Posts: 25
              Advanced Member
                I ended up just making the boxes 1 character and output only. That works. I will try the disabled.

                I am seeing one more oddity. As I move the data from the hidden field to the select box and then from the select box back to the hidden field on blur, it is putting spaces in front of the field. Can I do a trim on that before putting back in the hidden field for updating?

                I just went back to reading the employee table for the initial name on a query. That's where I get it from anyway. It may have been an issue with the spaces, but I am not sure.
                Randy Jacoy
                Veteran Member
                Posts: 46
                Veteran Member
                  You can do a portalWnd.strTrim() function on the string to remove spaces from the front and back but be careful.  Some Infor fields are left padded with spaces in the database and you may need to preserve them. 
                  Bill Alt
                  Advanced Member
                  Posts: 25
                  Advanced Member
                    I have a question or two about some strange behavior in the form. The form has all of the fields as select fields except the last field. On init or after a transaction (inquiry/change), the cursor is positioned in the last field even though I put in a positioninfieldbyid. I put in alerts and can see it pop in there, but then it goes back to the last field. Second, the list fields only allow drop down entry. You can't enter anything free form. Is this normal behavior for select fields? Thanks again.
                    Randy Jacoy
                    Veteran Member
                    Posts: 46
                    Veteran Member

                      Click on Edit ---> Tab Order.  Is the text box the first field in the list?  If so, that's where your cursor will go.  Set your select box as the first field in the list and you don't need to use positioninfieldbyid.

                      And apparently in Infor v10 the list box is a true list box rather than a combo box.  In version 9 you had the option of typing a new value into the combo box but not in version 10.  You can only type in an existing item.

                      Bill Alt
                      Advanced Member
                      Posts: 25
                      Advanced Member
                        Thanks. I remember seeing that but thought it was just for tab order, not field order.

                        I do remember those combo boxes. It didn't dawn on me that they were removed. Thanks for that explanation.
                        You are not authorized to post a reply.
                        Page 2 of 2 << < 12