Need help with a dynamic button

I would like to use a button to be loaded from a database with the location of a product. (https://shop1.warthogfirearms.com/catalog.php?search_for=810027773173)

I am using a default button and would like to know how to load the location so when the button is pressed it will go to the https:// location.
I have done this before so do I just use an anchor button?

The choice between an anchor (<a>) and a button (<button>) in HTML depends on the functionality you want to achieve:

  • Anchor (<a>): Use this when you want to navigate to another page, section, or resource. Anchors are designed for hyperlinks and are ideal for navigation purposes. For example:

    <a href="https://example.com">Go to Example</a>
    
  • Button (<button>): Use this for actions like submitting a form, triggering JavaScript functions, or interacting with the current page. Buttons are meant for user interactions that don't involve navigation. For example:

    <button onclick="alert('Hello!')">Click Me</button>
    

Key Differences:

  1. Semantics: Anchors are for navigation, while buttons are for actions.
  2. Attributes: Anchors use href for links, whereas buttons use type (e.g., submit, reset, or button).
  3. Accessibility: Buttons are focusable and can be triggered with the space key, while anchors are triggered with the enter key.

If you're styling an anchor to look like a button, ensure it still behaves like a link for accessibility. Similarly, avoid using buttons for navigation to maintain semantic clarity.

1 Like

Ben
Thanks using your input I was able to get the button to work the way I wanted it to.
anchor button - Dynamic Attributes - link

1 Like