Pass input tag value to as href parameter
The easiest way to do it with link and without any library:
<input type="text" id="qta_field" value="${item.value}"/>
<a href='' onclick="this.href='updateItem?codice=${item.key.codice}&quantita='+document.getElementById('qta_field').value">update</a>
How to pass input value to href
use get
method
<form action="index.php" method="GET">
<input type="search" name="search" />
<input type="submit" name="submit" />
</form>
OR
<form action="index.php" method="GET">
<input type="search" name="search" />
</form>
and in php you grab the value by $_GET['search']
how to pass two text box value to a href link
It is a good practice to write your script in a function & call it on HTML tags.
So, here's your working demonstration with your scenario -
function changeUrl() { let lattitude = document.getElementById('lat3').value; let longitude = document.getElementById('lon3').value; let target = document.getElementById('myAnchor'); let seperator = encodeURI(","); let href = 'https://www.google.com/maps/dir/?api=1&origin=' + lattitude + seperator + longitude + '&destination=2.183180,102.261803'; target.href = href; console.log(target.href);}
<a target="_blank" href="" onclick="changeUrl()" id="myAnchor">map</a> <input type="text" value="1234.5678" id="lon3"><input type="text" value="0567.1211" id="lat3">
PHP Passing Input values through href to another page
Your variable not parse inside single quotes. your <? echo '$data['id']' ?>
should be <?php echo $data['id'] ?>
<input type="text" name="a" id="a" />
<a href="xxx.php?id = <?php echo $data['id'] ?>&mk=">CLICK</a>"
<a id="link" href="xxx.php?id=111&mk=">CLICK</a>
Edit:-
simply add one more hidden fields to store id value as well and get value in js and assign to href
<input type="text" name="idval" id="idval" value="100" />
<input type="hidden" name="mk" id="mkval" value="101" />
Js:-
var idval = $('#idval').val();
var mk = $('#mkval').val();
var link = 'xxx.php?id=' + idval + '&mk=' + mk;
$("#link").attr("href", link);
Working Demo
Related Topics
How to Download File in React Js
How to Correctly Use Axios Params With Arrays
Wait for Http Request in Angular
Add Two Numbers and Display Result in Textbox With JavaScript
Disable/Hide Download Button in Iframe on Default Pdf Viewer
The Use of the Triple Exclamation Mark
Creating a Json Dynamically With Each Input Value Using Jquery
How to Print Star Pattern in JavaScript in a Very Simple Manner
How to Show Which Question a User Is on When Taking My Quiz
How to Include External JavaScript Library in Reactjs
Trouble Converting Dates String to Yyyy-Mm-Ddthh:Mm:Ss-Hh:Mm Format
How to Have Multiple Buttons of Same Id Value and When Click on Any Button the Pop-Up Should Come
How to Set a Value to a File Input in HTML
How to Loop Through Json Array and Get Specific Values
How to Add Multiple Values in Json Object and Get an Updated Json File