onclick window.location.href with input value

user2397282

I have an input and I want the user to be sent to another page with the input's value in the URI so that I can extract it.

This is how my input is set up:

<input name="date" id="datepicker" onchange="window.location.href = 'test.php?Date=' + document.getElementById("datepicker").value;">

Basically, when the date is changed, the date should be added onto the end of the URI and the user should be sent to test.php, where the value will be extracted. However, the value doesn't seem to be added on.

What's the problem?

putvande

Try:

<input name="date" id="datepicker" onchange="window.location.href = 'test.php?Date=' + this.value;">

You don't need to do document.getElementById('datepicker') since the element you are in is already the one you want the value from.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

onclick window.location.href with input value

From Dev

Javascript window.location.href onClick not working

From Dev

Javascript window.location.href onClick not working

From Dev

How to pass Id value to window.location.href in MVC application

From Dev

window.location or window.location.href not changing the value in all browsers MVC application

From Dev

String is not a function on window location href

From Dev

window.location.href not working

From Dev

bootstrap button onclick and location.href

From Dev

How to add a $variable to a onclick="location.href='

From Dev

Enable and disable window.location.href

From Dev

Passing parameter through "window.location.href"

From Dev

onchange event on window.location.href

From Dev

Window.location.href infinite loop

From Dev

Stubbing window.location.href with Sinon

From Dev

window.location.href not working in IE 11

From Dev

Using a variable for if window.location.href.indexOf()

From Dev

$window.location.href NOT WORKING in AngularJS

From Dev

window.location.href appending instead of replacing

From Dev

JavaScript window.location.href not working in localhost

From Dev

window.location.href is not redirecting html page

From Dev

window.location.href not working on IE

From Dev

How to Pass QueryString in window.location.href?

From Dev

window.location.href - help redirecting

From Dev

Use of window.location.href in crosswalk

From Dev

window.location.href and hash are not working on chrome

From Dev

Window.location.href infinite loop

From Dev

find a tag that contains the window.location.href

From Dev

window.location.href not working as expected

From Dev

Passing parameters using Window.location.href

Related Related

HotTag

Archive