My code below works if I manually set the value of command, but if I try to get the value dynamically the code stops working altogether. I isolated the line of code which seems to be the problem(comment after it saying it is where the error is).
If I comment the line alert(document.getElementById("cdmTxt").value); it works as intended.
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb">
<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<script type='text/javascript'>
function exec(){
alert("hi");
alert(document.getElementById("cdmTxt").value); //does not seem to execute???
var command = "word";
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var txtToUpdate = document.getElementById("txtHint");
txtToUpdate.innerHTML = txtToUpdate.innerHTML + xmlhttp.responseText + "<br/><br/>";
}
}
xmlhttp.open("GET", "HAS-sync.php?exec=" + command, true);
xmlhttp.send();
}
</script>
<style type="text/css">
.auto-style1 {
margin-top: 0px;
}
</style>
</head>
<body>
<table style="width: 100%">
<tr>
<td style="width: 141px; height: 390px">Managers<br /> DHTs</td>
<td name="targetThing" style="height: 390px">
<form onsubmit="exec();return false">
<input id="cmdTxt" class="auto-style1" name="Text1" type="text">
<input type="submit">
</form>
<br />
<div id="txtHint" style="overflow: scroll; border:1px solid black;width:80%;height:80%"></div>
</td>
</tr>
</table>
</body>
</html>
Any help with this is greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire