How do you add parameters in html?


Example

Set the "autoplay" parameter to "true", so the sound will start playing as soon as the page loads:


 

Try it Yourself »


Definition and Usage

The tag is used to define parameters for an element.


Browser Support

The tag is supported in all major browsers. However, the file format defined in may not be supported in all browsers.

Element
Yes Yes Yes Yes Yes

Attributes

AttributeValueDescription
name name Specifies the name of a parameter
value value Specifies the value of the parameter

Global Attributes

The tag also supports the Global Attributes in HTML.


Event Attributes

The tag also supports the Event Attributes in HTML.


HTML DOM reference: Parameter Object


Default CSS Settings

Most browsers will display the element with the following default values:


Currently I'm at

http://example.com/topic.php?id=14 

and I want to make a link to

http://example.com/topic.php?id=14&like=like 

by not defining the current url. Like Like. However this last one shows me http://example.com/&like=like

How do you add parameters in html?

asked Dec 19, 2011 at 14:15

How do you add parameters in html?

1

There is no way to write a relative URI that preserves the existing query string while adding additional parameters to it.

You have to:

topic.php?id=14&like=like

answered Dec 19, 2011 at 14:19

QuentinQuentin

875k121 gold badges1172 silver badges1286 bronze badges

4

function currentUrl() {
    $protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https';
    $host     = $_SERVER['HTTP_HOST'];
    $script   = $_SERVER['SCRIPT_NAME'];
    $params   = $_SERVER['QUERY_STRING'];

    return $protocol . '://' . $host . $script . '?' . $params;
}

Then add your value with something like;

echo currentUrl().'&value=myVal';

answered Dec 19, 2011 at 14:23

How do you add parameters in html?

Marco PaceMarco Pace

3,79918 silver badges38 bronze badges

I know I'm late to the game, but you can just do ?id=14&like=like by using http build query as follows:

http_build_query(array_merge($_GET, array("like"=>"like")))

Whatever GET parameters you had will still be there and if like was a parameter before it will be overwritten, otherwise it will be included at the end.

answered Jan 17, 2017 at 17:10

How do you add parameters in html?

2

In case you want to add the URL parameter in JavaScript, see this answer. As suggested there, you can use the URLSeachParams API in modern browsers as follows:




...
  Like this page
...

answered May 10, 2019 at 17:04

mrtsmrts

14.5k6 gold badges83 silver badges67 bronze badges

If you wish to use "like" as a parameter your link needs to be:

Like

More likely though is that you want:

Like

answered Dec 19, 2011 at 14:21

spanspan

5,5688 gold badges54 silver badges111 bronze badges

It is not elegant but possible to do it as one-liner element

Like

answered Mar 16, 2020 at 14:40

How do you add parameters in html?

Kamil KiełczewskiKamil Kiełczewski

75.7k26 gold badges335 silver badges311 bronze badges

Maybe you can write a function as follows:

var addParams = function(key, val, url) {
  var arr = url.split('?');
  if(arr.length == 1) {
    return url + '?' + key + '=' + val;
  }
  else if(arr.length == 2) {
    var params = arr[1].split('&');
    var p = {};
    var a = [];
    var strarr = [];
    $.each(params, function(index, element) {
      a = element.split('=');
      p[a[0]] = a[1];
      })
    p[key] = val;
    for(var o in p) {
      strarr.push(o + '=' + p[o]);
    }
    var str = strarr.join('&');
    return(arr[0] + '?' + str);
  }
}

answered Sep 10, 2016 at 2:28

killernovakillernova

1501 silver badge11 bronze badges

How do you create parameters in HTML?

Definition and Usage. The tag is used to define parameters for an element..
Browser Support. The tag is supported in all major browsers. ... .
Attributes. Attribute. ... .
Global Attributes. The tag also supports the Global Attributes in HTML..
Event Attributes. ... .
Related Pages..

How do I add parameters to a URL in HTML?

Any word after the question mark (?) in a URL is considered to be a parameter which can hold values. The value for the corresponding parameter is given after the symbol "equals" (=). Multiple parameters can be passed through the URL by separating them with multiple "&".
Keep the following in mind when adding parameters directly to a landing page URL:.
Make sure the first parameter is preceded by the ? ... .
Separate the second, third, and any subsequent parameters with & ..
Don't include spaces in the query string..
Don't use any of the reserved parameters as the name of a parameter..

How do I add a parameter to a form?

Add a parameter to a query.
Create a select query, and then open the query in Design view..
In the Criteria row of a field for which you want a parameter applied, type the text that you want the parameter dialog box to display, enclosed in square brackets, for example:.