Did you include the 'json2.js' script at the top of your page? It must be the only reason or it has got something to do with your HTML file since stringify() works for me.
<html>
<head>
<title>Forms</title>
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript">
function somename() {
var o = objectify();
var jsonString = JSON.stringify(o);
alert(jsonString);
}
function objectify() {
var o = {};
var frms = document.forms;
var formID = 1;
var id = 1;
for (i = 0, maxI = frms.length; i < maxI ; i++) {
if (frms[i].name == 'form' + formID) {
var frm = frms[i];
var elms = frm.elements;
var tmp = {};
for (var j = 0, maxJ = elms.length; j < maxJ; j++) {
var el = elms[j];
tmp[el.name] = el.value;
}
o[frm.name] = tmp;
formID++;
}
}
return (o);
}
</script>
</head>
<body id="bdy">
<form name="form1" action="#">
<input name = "txtOne" value = "Text box one" />
<input name = "txtTwo" value = "Text box two" />
<input name = "txtThree" value = "Text box three" />
</form>
<form name="form2" action="#">
<input name = "txtOne" value = "Text box one" />
<input name = "txtTwo" value = "Text box two" />
<input name = "txtThree" value = "Text box three" />
</form>
<form name="form3" action="#">
<input name = "txtOne" value = "Text box one" />
<input name = "txtTwo" value = "Text box two" />
<input name = "txtThree" value = "Text box three" />
</form>
<script>somename();</script>
</body>
</html> "I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."