Сообщение от php-coder
|
генерирую строку вида
'{"12": 150, "13": 150, "14": 100}'
|
Как вариант...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251' />
<script src='http://code.jquery.com/jquery-latest.js'></script>
<!--
<script src="https://code.angularjs.org/1.3.9/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.9/angular-route.js"></script>
<link rel='stylesheet type=text/css href=tmp.css' />
<link rel="stylesheet/less" type="text/css" href="style.less">
<script src="http://cdnjs.cloudflare.com/ajax/libs/less.js/2.5.0/less.min.js"></script>
-->
<style type='text/css'>
</style>
<script type='text/javascript'>
$(function(){
var obj={};
$('[name^=dataId]').each(function(){
var key=this.name.match(/\d+/);
obj[key]=this.value;
});
console.log(obj);
});
</script>
</head>
<body>
<form>
<input name="dataId[0]" value="10" type="text" />
<input name="dataId[1]" value="20" type="text" />
<input name="dataId[2]" value="30" type="text" />
<input name="dataId[3]" value="40" type="text" />
<input name="dataId[4]" value="50" type="text" />
</form>
</body>
</html>