pass dynamic values in json data in java script means when i am changing combo box i want to store values from combo box to json in key -value pair and finally also want length of JSON
anyone please help me ......
Here is my code
<script type="text/javascript">
var graphArray =new Object();
function changeConcentration()
{
substance=$("#substance").val();
concentration=$("#concentration").val();
ans = substance*concentration;
}
function calculateMeasurement()
{
var a=0;
if($("#answer").val()==ans)
{
graphArray={ "concentration" : concentration,"answers" : ans }; //my json
if(graphArray.length>=6)
{
//some task to be done
}
}
}
</script>
</head>
<body>
<table border="0" align ="left">
<tr><td>Substance</td><td>:</td>
<td>
<select id="substance">
<option>Select</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</td>
</tr>
<tr><td>Concentration</td><td>:</td>
<td><select id="concentration" onChange="changeConcentration();">
<option>Select</option>
<option>5</option>
<option>10</option>
<option>30</option>
</select>
</td>
</tr>
<tr><td>Cell Constant</td><td>:</td>
<td><select name="cell_constance">
<option>Select</option>
<option>10.0</option>
</select>
</td></tr>
<tr><td>Specific Conductance at 250C</td><td>:</td><td><input id="answer" type="text" name="answer"></td></tr>
<tr><td></td><td></td><td><input type="Submit" value="Submit" onclick="calculateMeasurement()"/></td></tr>
</table>
</body>
</html>