Summary
Using either string concatenation or string interpolation (via template literals ).
Here with the JavaScript template literal:
function geoPreview() { var lat = document.getElementById("lat").value; var long = document.getElementById("long").value; window.location.href = 'http://www.gorissen.info/Pierre/maps/googleMapLocation.php?lat=${lat}&lon=${long}&setLatLon=Set'; }
Both parameters are not used and can be deleted.
remarks
String concatenation
Attach strings using the + operator:
window.location.href = "http://www.gorissen.info/Pierre/maps/googleMapLocation.php?lat=" + elemA + "&lon=" + elemB + "&setLatLon=Set";
String interpolation
For more concise code, use JavaScript template literals to replace expressions with their string representations. Pattern letters are enclosed in '' and placeholders surrounded by ${} :
window.location.href = 'http://www.gorissen.info/Pierre/maps/googleMapLocation.php?lat=${elemA}&lon=${elemB}&setLatLon=Set';
Template literals are available since ECMAScript 2015 (ES6).
Flashover
source share