How can I create a dynamic URL in HTML?

A dynamic URL is a URL that can change based on many factors. To create a dynamic URL in HTML, you can use a combination of HTML, JavaScript, and PHP.

Here's an example of how you might create a dynamic URL using an HTML form and JavaScript:

Javascript Dynamic Url

<a href="" id="dynamic-link">Click here</a>

var link = document.getElementById("dynamic-link");
function makeid(length) {
    let result = '';
    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    const charactersLength = characters.length;
    let counter = 0;
    while (counter < length) {
      result += characters.charAt(Math.floor(Math.random() * charactersLength));
      counter += 1;
    return result;
// link.href = makeid(10);

Check Demo

Php Dynamic Url

echo dynamicUrl(10);

// create a function for generating url
function dynamicUrl($len=6) {
   $str ='1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
   $link = substr($str, 0, $len);
   return '<a href="'.$link.'">Click me - '.$link.'</a>';


Added  Feb 13, 02:27 pm

Article tags

SignUp with Email