This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Programmatically adding new items/values to form

klancicj - Monday, October 13, 2014 9:43 AM:

Hello everyone!

I am currently struggling with the a small problem. I am looking for a way to add values, when a button is pressed. I can call a method, when the button is pressed and I can also retrieve the wanted information. But I do not find any steps how to add values to form items, when the form is already shown. When the window/form is shown, the listbox is still empty, because the listbox has to be filled, when a certain action is triggered.

I went through the forms in the Innovator, but I did not find not even one solution to my problem. I went through the examples, documentation and so on, but I have no clue what is the best practice. I created a form, where I have a button. By pressing the button, a JavaScript/client method is invoked and the client calls the business logic. The value is returned to the client and has to be set into the Listbox - I am trying to add an array of values to the Listbox. How can I programatically add values to the Listbox. Should I write the reference of the Lisbox name and set those array values by going with something like "this.form.listbox.value" and then afterwards refresh the form. In this way the value is linked to the form item (the linked value to the item is then set) and I only have to refresh the page after the set. OR is there another way to deal with it? Should I rather create an custom HTML code if I am trying to programmatically add stuff to the window?

If the first option is possible, is there somewhere written how you can pass values to those items? I know I can get the value of a filled textfield through this.form.ITEM_NAME.value. Can you get all the values (Radio button list, listbox, etc) from the form items like this? Can you also set those value like this and then only refresh the window?



klancicj - Tuesday, October 14, 2014 2:09 AM:

I do not get it what is the best way to manipulate items on a window, which is already open. I could make a HTML placeholder, where I would inject my code. But how can I do that. I looked how to make a placeholder like div with an ID and then inject the content by calling JavaScript referring to the ID.

Another option is to use the form objects and then inject the values to the items. But again, how do you inject those values? I did not find any way to add items to a Listbox, when the Listbox is already placed and shown in a window. I probably have to use JavaScript again to do so. But how? How can I refer to the item and then set the value. Afterwards I probably have to refresh the window, otherwise the set values are not displayed - correct me if my understanding is false.



klancicj - Wednesday, October 15, 2014 3:48 AM:

After looking into the system and a few examples, I think I have the answer. Rather then manipulating form items, I will open a new window. This window will contain HTML, where my results will be injected into tables, inputs, etc. This way I have full control over the whole window and I can get DOM elements through JavaScript. I do not know if this concept is the right one, but for now I can not imagine to implement my task in any other way.