Skip to main content

Button Submit Action

  1. Navigate to HSYCO Manager

  2. Create a new project or open an existing one

  1. Go to Home page

  1. Click "add"

  1. Add a "Button"

  1. Click "edit"

  1. Because this will be the submit button, we can align it to the bottom and also centering it horizontally

  1. Change the "Label" to "Submit Values"

  1. Change the "Action" to "submit"

Tip: Now we'll add the two text fields and the date field to be submitted

  1. Click "add"

  1. Add a "Field" under the "Form" tab

  1. Click "edit"

  1. Align it to the top and also centered horizontally

14. Change the "Name" attribute to "name". This will be the name of the attribute that will be passed when we press the submit button

  1. Change the "Placeholder" to "Name"

  1. Click "add"

  1. Add another "Field"

  1. Go back to "edit" mode

  1. Align it under the other text field

  1. Change the "Name" to "surname"

  1. Change the "Placeholder" to "Surname"

  1. Click "add"

  1. Add a "Date" object

  1. Click "edit"

  1. Align it under the two fields

  1. Change the "Name" to "date"

  1. Click "add"

  1. Add a "Text" area

  1. Click "edit"

  1. Change the "ID" to "textarea"

  1. Move the text area to the right of the form and resize it

  1. Leave the "Text" attribute blank as it will be modified dynamically

  1. the page should look like this:

  1. Click "Save" to save the project

Tip: Now we'll download from GitHub a small piece of code that captures the command launched from the submit button and shows the different fields in the text area

  1. Navigate to https://github.com/hsyco/hsyco4-examples

  2. Click "Code"

  1. Click "Download ZIP"

  1. Now extract the .zip file and navigate into the /button/submitAction folder to find the submit.txt file

  2. Go into the "File Manager"

  1. Navigate into the "events" folder

  1. Click "Upload Files"

  1. Select the submit.txt file previously extracted and press "Upload"

  1. The file has been uploaded

44. The function userSubmit is called when a submit button is pressed. Here, we retrieve all the values from the different form objects and, for every one of them, we add the name of the attribute and its value to a string. This string is then displayed through a uiSet() in the "text" attribute of the object with ID "textarea"

Tip: Done! Now we can try to submit some values and see them in the text area

  1. Click "Run" and then "Default" to launch the application

  1. Fill the "Name" field

  1. Fill also the "Surname" field

  1. Select a date

  1. Press "Submit Values"

  1. As you can see, the values has been sent and captured by the code that displayed them in the text area

  1. We can also check in the "Log Viewer" if the command has been sent

52. As you can see, the command has been sent. All the fields are separated by a '@' and the structure is : AttributeName@Value. The "_8" near the Web User Commands indicated the object that launched the command. In our case, because we didn't defined an ID for the submit button, it automatically selected "_8". If we had given the button an ID, we would see that instead of the "_8"