Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2

    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").
    Daryl G

  2. #2
    Join Date
    Apr 2013
    Posts
    226
    Hi,

    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?

    Matty

  3. #3
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    Matty,
    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!
    Daryl G

  4. #4
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    See attached.
    Whatever you type into the text field will appear on the button.

    Regards
    James
    Attached Thumbnails Attached Thumbnails screen.jpg  
    Attached Files Attached Files

  5. #5
    Join Date
    Apr 2013
    Posts
    226
    Hi James,

    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.

    Matty

  6. #6
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Hi Matty.
    Yes, it's a custom HTML field.

    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.

    Regards
    James.

  7. #7
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    James,
    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.
    Daryl G

  8. #8
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Hi Daryl.

    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.

    Regards
    James.

  9. #9
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    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.

    I'll file a bug report on this.

    Regards
    James
    Attached Files Attached Files

  10. #10
    Join Date
    Sep 2011
    Location
    Australia
    Posts
    264
    Provided Answers: 2
    Hi all
    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.
    Regards
    David
    Attached Files Attached Files

  11. #11
    Join Date
    Jan 2014
    Posts
    46
    Hi
    Did anyone else get an "unknown format" message with David's file?
    Don

  12. #12
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Quote Originally Posted by donaldp View Post
    Hi
    Did anyone else get an "unknown format" message with David's file?
    Don
    Same here.

    James

  13. #13
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    I, too, get an unknown format error.

    James,
    WOW! I am gong to have to take a long, hard look at what you did. Are those buttons made with 'user functions'?
    Daryl G

  14. #14
    Join Date
    Sep 2011
    Location
    Australia
    Posts
    264
    Provided Answers: 2
    Hi again
    Not sure what happened to file - would not open for me as well.
    Tried again with new upload.
    Regards
    David
    Attached Files Attached Files
    Last edited by tamcind; 03-12-14 at 17:05.

  15. #15
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Quote Originally Posted by fireant911 View Post
    James,
    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.

    Code:
    <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.

    Regards
    James.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •