• json


    将json数据写入对应的table中。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    
        <title></title>
        <script src="jquery-2.0.0.js"></script>
        <script type="text/javascript">
        function json_value(){
        	var value_1 = '{"spectrum":[{"spec_freq":111,"spec_type":2, "spec_lo":132},
        	{"spec_freq":151,"spec_type":2, "spec_lo":129}],"take":"12fdsafds"}';
        	var value_2 = eval("("+value_1+")");
        	//console.log(value_2.spectrum[1].spec_lo);
        	//alert((value_2.spectrum[1].spec_lo));
        	console.log(value_2.spectrum.length); //读取数组长度
        	return value_2.spectrum;
    
        }
    
        function test() {
        	var spec = ["spec_freq", "spec_type", "spec_lo"];
        	var spectrum_tol = json_value();
        	spectrum_tol[1][spec[0]] =  250;
        	for (index_tol in spectrum_tol)
        	{
        		for (index_spec in spec)
        		{
        			if (spec[index_spec] != "spec_type")
        			{
        				$('[name="'+spec[index_spec]+'"]').eq(index_tol).text(spectrum_tol[index_tol][spec[index_spec]]);
        			}    
        			else
        			{
        				$('[name="'+spec[index_spec]+'"]').eq(index_tol).val(spectrum_tol[index_tol][spec[index_spec]]);
        			}			
        		}
        	}
         } 
        </script>
    </head>
    
    <body onload="json_value();">
        <table border="1" width="90%" align="center">
        	<tr align="center">
        		<td name="spec_freq">1</td>
        		<td width="20%">
        			<select name="spec_type" style="100%" dir="ltr">
        				<option value="1">1</option>
        				<option value="2">2</option>
        			</select>
        		</td>
        		<td name="spec_lo">1</td>
        	</tr>
        	<tr align="center">
        		<td name="spec_freq">2</td>
        		<td>
        			<select name="spec_type" >
        				<option value="1">1</option>
        				<option value="2">2</option>
        			</select>
        		</td>
        		<td name="spec_lo">2</td>
        	</tr>    	
        </table>
        <table width="90%" align="center">
        	<tr>
    	    	<td align="right">
    	    		<input type="button" style="200px" name="test"  value="test" onclick="test();">	
    	    	</td>    		
        	</tr>
        </table>
    
    </body>
    
    </html>
    

      

  • 相关阅读:
    平均值的最值化
    GCJ 2008 R3 C 二分图匹配
    BZOJ 1013 高斯消元
    NOIP2015 d2T3 二分+树上前缀和
    9.7集训 总结
    BZOJ 1026
    BZOJ 3223
    NOIP前夕:codevs,关路灯
    NOIP前夕:codevs,解药还是毒药
    NOIP前夕:codevs,修剪花卉
  • 原文地址:https://www.cnblogs.com/liuyang92/p/6076080.html
Copyright © 2020-2023  润新知