I am trying to make a webpage where I enter a latitude and longitude and a python program will process the latitude and longitude in the form of a graph. For simplicity sake, in this question I just have the python program just repeat the latitude and longitude because I am wanting to know how to run the python program in the context of the html and javascript code and pass the arguments from the html form (latitude and longitude) into the python script. Below is the html code:
<html>
<head>
<script>
function set_iterations()
{
var count = 0;
var lat = document.getElementById("lat").value;
var lon = document.getElementById("lon").value;
document.write("latitude is " + lat + " and longitude is " + lon + "</br>");
$.ajax({
type: "POST"
url: "testmaker.py" + lat + lon
});
}
</script>
</head>
<body>
<td style='border-right:none' align='center'>Latitude: </td>
<td style='border-right:none' align='center'><input type=text id='lat' size=10></td>
<td style='border-right:none' align='center'>Longitude: </td>
<td style='border-right:none' align='center'><input type=text id='lon', size=10></td>
<br>
<button style="width:200px;margin-top:5px;margin-bottom:20px;" onClick="set_iterations();">Submit</button>
</body>
</html>
The python program is this:
#!/usr/bin/python
import sys
latitude = sys.argv[1]
longitude = sys.argv[2]
print "Using coordinates: ",latitude,",",longitude
How should I modify this program so that the submit button on the form would call the python program with the entries in the form being command line arguments for the python program?
"