Quote from no1g8tor96 on November 1, 2022, 4:45 amI am new to this platform and looking for a suggestion on how to do a simple task.
I need a Text Box that has 2 buttons under it. One box is say 1 and the other is 2
When i click button 1 it will put "this is 1"under the last line in the box. If its the first line then its the top line then say i press button 2
It needs to say "this is 2" under what was the last line in the box
so the program will create this based on the buttons pressed?
example...
this is 1
this is 1
this is 2
this is 1
this is 2
etc.
I am new to this platform and looking for a suggestion on how to do a simple task.
I need a Text Box that has 2 buttons under it. One box is say 1 and the other is 2
When i click button 1 it will put "this is 1"under the last line in the box. If its the first line then its the top line then say i press button 2
It needs to say "this is 2" under what was the last line in the box
so the program will create this based on the buttons pressed?
example...
this is 1
this is 1
this is 2
this is 1
this is 2
etc.
Quote from Gaev on November 1, 2022, 8:37 pm@no1g8tor96
1) For your "TextBox", choose a "Container" ... let us name it (i.e. give it an id of) "MessageContainer"
2) Here is your code for Button1 ...
SetVar "[thisButtonMessage]" "this message from Button1" GetObjectHTML "MessageContainer" [containerHTML] StrLen "[containerHTML]" [containerHTMLLen] ...AlertBox "containerHTML" "[containerHTMLLen]...[containerHTML]" "" If [containerHTMLLen] <= 1 ... this is first line in Container SetVar "[newLine]" "" Else SetVar "[newLine]" "<br/>" ... for double spaced lines ...SetVar "[newLine]" "<br/><br/>" EndIf SetObjectHTML "MessageContainer" "[containerHTML][newLine][thisButtonMessage]"
For each of the other buttons, just change the first line of script to whatever you want.
Notes:
a) to check if this is the first line or not (which determines whether you need a new line element of "< br/ >" or not), I had to check the length of the stored HTML (apparently it stores a single blank character even when empty).
b) if you want the text lines to appear double spaced, just add an additional new line element of "< br/ >" to [newLine]
1) For your "TextBox", choose a "Container" ... let us name it (i.e. give it an id of) "MessageContainer"
2) Here is your code for Button1 ...
SetVar "[thisButtonMessage]" "this message from Button1" GetObjectHTML "MessageContainer" [containerHTML] StrLen "[containerHTML]" [containerHTMLLen] ...AlertBox "containerHTML" "[containerHTMLLen]...[containerHTML]" "" If [containerHTMLLen] <= 1 ... this is first line in Container SetVar "[newLine]" "" Else SetVar "[newLine]" "<br/>" ... for double spaced lines ...SetVar "[newLine]" "<br/><br/>" EndIf SetObjectHTML "MessageContainer" "[containerHTML][newLine][thisButtonMessage]"
For each of the other buttons, just change the first line of script to whatever you want.
Notes:
a) to check if this is the first line or not (which determines whether you need a new line element of "< br/ >" or not), I had to check the length of the stored HTML (apparently it stores a single blank character even when empty).
b) if you want the text lines to appear double spaced, just add an additional new line element of "< br/ >" to [newLine]