Search code examples
javascripthtmlhref

Send text field value using href to php


I have to send text field value using href to php is something like below. But it is not correct way. Can anyone please give me any solution?

<input type="text" id="myText" value="Mickey">
<a href="test.php?id=javascript:document.getElementById('myText').value;">
<input type="button" value="Click"></a> 

Solution

  • <input type="text" id="myText" value="Mickey">
    <a href="test.php" onclick="this.href = this.href +'?' + document.getElementById('myText').value;">test</a>