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()
		 ans = substance*concentration;			
	function calculateMeasurement()
		var a=0;
				graphArray={ "concentration" : concentration,"answers" : ans }; //my json
					//some task to be done
			<table border="0" align ="left">
						<select id="substance">
					<td><select id="concentration" onChange="changeConcentration();">
				<tr><td>Cell Constant</td><td>:</td>
				<td><select name="cell_constance">
				<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>


if you want the length, you need to use an array.

//Create array
var graphArray =new Array();
// Add item to array
graphArray.push({ "concentration" : concentration,"answers" : ans });
// Alert array length

But your code has some problems, for example: the options has no value, so the changeConcentration() function is not working.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.