I want print the dict a in alert , (it is possible?) or print in the third's textarea (three) with id=p
.
I read on this question and I used
document.getElementById("p").value=JSON.stringify(a);;
alert("myObject is " + a.toSource());
console.log(a);
These not function. The example is :
<!DOCTYPE HTML>
<html>
<head>
<title>Example - print the dict</title>
</head>
<body>
<input id = 'button1' type = 'button' value = 'print the dict' onclick="updateHistory()"/>
<script type = 'text/javascript'>
var count ="?foo=1&oo=298529982";
function updateHistory()
{
var a = new Array();
for (var i = 0; i < document.formparam.elements.length; i++)
{
var field = document.formparam.elements[i];
a[field.name] = field.value;
}
document.getElementById("p").value=JSON.stringify(a);;
alert("myObject is " + a.toSource());
console.log(a);
}
</script>
<form method="GET" name="formparam" id="formparam" ><table><tr><td><textarea name="name" >john</textarea></td><td><textarea name="surname">jackold</textarea></td></tr></table></form>
<textarea id="p"></textarea>
</body>
</html>