I have a form with a css submit button. When a the submit button is clicked, i call a function that executes:
document.forms["request"].onsubmit();
What should happen, then, is that the onsubmit method ought to be triggered. This works properly in Chrome/FF, but for some reason IE/Safari will bypass the onsubmit function and simply add the parameter "address=" onto the url as if it were submitting the form and ignoring the onsubmit function. Heres the code for the form:
<form id="request" method="get" onsubmit="addLocation(this.address.value); return false;">
<br>
<label style="position:relative;left:5px;" for="address">Enter an intersection or address:
</label>
<br>
<br>
<input style="height:35px; width:300px;position:relative;bottom:1px;left:10px;" id="address" name="address" class="required address"/>
<a style="float:right;right:120px;position:relative;" class="button" onclick="submit();">
<span>Submit Request
</span>
</a>
</form>
and what follows are some relevant js functions:
function addLocation(address) {
if (geocoder) {
geocoder.getLocations(address, function (point) {
if (!point) {
alert(address + " not found");
} else {
if (point.Placemark[0].address != submittedString) {
submittedString = point.Placemark[0].address;
addRow(point.Placemark[0].address);
req = "addrequest?truck=" + "coolhaus&address=" + point.Placemark[0].address;
alert(req);
addRequest(req);
request.onreadystatechange = function () {}
}
}
});
}
}
function addRequest(req) {
try {
request = new XMLHttpRequest();
} catch (e) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("XMLHttpRequest error: " + e);
}
}
request.open("GET", req, true);
request.send(null);
return request;
}
You can test the form here:
http://la.truxmap.com/request?id=grillmastersla
Thanks so much!