Unanswered: Dynamic Button Naming - is it possible through scripting?
Is it possible to use scripting to change the names of buttons? My current project has several buttons and if I could programmatically change the naming of buttons when certain actions are performed, it would be grand. The only other option that I am aware of is to show/hide buttons but that approach would necessitate having buttons for every scenario... and that can get messy very quickly and I would rather not double/triple the number of buttons I currently have. I attempted the 'logical' thing and tried to use a variable name in the 'Name:' field in the form editor but that did nothing other than shown exactly the characters I typed (i.e., "[$available_procedures]" rather than the actual value of that variable - "Irrigation of ear").
What you could do is not give the button a name but instead create "fake" button names by placing URL fields over the button and control which is visible by using rules. You'd also have to style the url field to match the button. In theory you should be able to do this with static labels also but I cannot get them to appear on top of buttons - selecting order front or back on various form elements never seems to do anything for me. Is that any use?
That is an interesting approach. I, too, like the idea of using static labels but just as you mentioned, the labels cannot be placed on top of the buttons. I have never used the URL fields so I will give that a try. Many thanks!
Is that a custom HTML field? Looks neat. I guess the only potential issue might be that you don't get the button functionality such as running a script on click. Though you can I assume set it to call a user function using the "HTML UF Link" option?
I must look more at the custom HTML stuff as it seems to add yet more flexible functionality to BD.
The code in this example prevents brilliant database from showing scroll bars in the HTML field and if you do that in combination of using absolute position code, you can make the button appear as if it's just a normal button on the form.
In the example I have it displaying a simple web message when you press it, but I'm 100% confident that this method can be used to run brilliant database scripts.
As always, I am impressed with your knowledge! The functionality you demonstrated was what I was looking for... but I have 'loads' of script underneath the buttons that I was hoping to employ dynamic button naming on. Your solution certainly works nicely though I have no experience with HTML (and only minimal experience with Brilliant Database). I am amazed at the creativity that you have developed with this program.
You won't have to rewrite button scripts. All you will have to do is copy and paste them into User Functions and give them a relevant name. Once the code for each button is a User Function, you can use a HTML UF Link to get the HTML button to run the User Function script.
The code for the HTML button will never change. You insert two variables (switches) into the HTML code that you can dynamically change.
The first variable simply sets the button name text, as per the example I uploaded. The second variable will be title you gave the User Function. This will allow one single button to be assigned any User Function.
Scratch that idea for the moment. I decided to write an example showing how you can use HTML code to access any of brilliant database's functions and I ran into a show stopper bug that's limited to the HTML Field only.
So for the moment have a look at the attached example of this working outside the HTML field.
On the left where the folder are normally there are now 3 buttons. The first two simply tell brilliant database to go to different folders.
The third button however when pressed will run a User Function. This user function will ask you to enter your name. What you type in populates a brilliant database variable. Next it will display your name using the variable data with a brilliant database “show message” function.
Using this idea you can have one single button being able to do countless different operations. Only two pieces of information need to be changed. The button text and the name of the User Function it's to run. Both static bits of text in my example can be replaced with variables that allow the button to switch function.
As of now, this works in the folder area, and on a HTML page, but NOT for a HTML field. I suspect that this is a bug as HTML fields are only new to v10 of brilliant database.
Full marks to James for his efforts - I need to learn HTML. Would an alternate method of using blank buttons with text at side of button serve the purpose. Fairly easy to do with standard BD actions. There is a rough example attached to post to illustrate idea. Labels will change depending on user actions like edit text or click buttons- nothing special.
WOW! I am gong to have to take a long, hard look at what you did. Are those buttons made with 'user functions'?
No, the button itself is only bog standard HTML code.
This is the code for the button.
<button type="submit" formaction=<!Ask a Question!>Press This Button</button></a>
When you create a User Function in Brilliant Database, you have to give the user function an name. In this case, I called the user function “Ask a Question”.
If you look at the code above, you will see those 3 worlds.
If you replaced those 3 words with a Variable, you could use that variable to make the button access any User Function just by populating it with the name of the User Function.
Same goes for the name displayed on the button. Where it says “Press This Button”, that's the text that will be displayed on the button. You could insert a variable there too giving you the ability to change both the text displayed on the button and it's function.