demo.html 1.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
<!-- http://jibbering.com/2002/4/httprequest.html -->
<html>
<head><title>CDuce demo</title></head>
<body>

<h1><a href="http://www.cduce.org/">CDuce</a> online demo</h1>
<table width="100%" border="1">
<tr>
<td width="50%" valign="top">
<input type="submit" value="Evaluate" onclick="submit('a');"/>
<input type="button" value="Clear" onclick="clearreq('a');"/>
<textarea id="areq" cols="80" rows="25">
13
let x = 1;;
14 15 16 17 18 19 20 21 22
</textarea>
<br/>
</td>
<td width="50%" valign="top" onmousedown="show_result('a','');">
<input type="button" value="Clear" onclick="show_result('a','');"/>
<pre><div id="ares"></div></pre>
</td>
</tr>
</td>
23
<script type="javascript">
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

function clearreq(pr) 
{ document.getElementById(pr+"req").value = ""; }

function show_result(pr,res)
{ document.getElementById(pr+"res").innerHTML = res; }

function submit(pr) {
 var xmlhttp = new XMLHttpRequest();
 xmlhttp.open("POST", "/cgi-bin/evaluator" ,true);
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) { show_result(pr,xmlhttp.responseText); }
 }
 show_result(pr,"Computing...");
 xmlhttp.send(document.getElementById(pr+"req").value);
}


</script>
</body>
</html>