nedla2004 nedla2004 - 1 month ago 7
HTML Question

HTML Get Input Value

I am trying to make a link, and place a variable in the URL like this:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<a href="index.html?color=">Main Page</a>
<input type="color" id="colorPicker" value="#808080">
</body>
<html>


I am trying to send the user to
index.html?color=VALUE GOES HERE
. Instead of
VALUE GOES HERE
, I would like the current color input value.

Answer

The only way that I can think to do this is with JavaScript, so sorry if this is not what you are looking for:

function urlUpdate(hex) {
  document.getElementById("link").href = "index.html?color=" + hex;
}
<!DOCTYPE html>
<html>

<head>
</head>

<body>
  <a id='link' href="index.html?color=">Main Page</a>
  <input type="color" id="colorPicker" value="#808080" onchange="urlUpdate(value)">
</body>
<html>