我有这个表格的 HTML 代码:
<table id="portfolios" width="500" border="1" align="center" height="300">
<thead class="colHeaders">
<tr><th class="weight" bgcolor="#999999"><h4> Weight in Motif </h3></th>
<th class="name" bgcolor="#999999"><h4> Segment & Stocks</h3></th>
<th class="price" bgcolor="#999999"><h4> Name of stock </h3></th>
</thead>
<tr id="titles" value="Disable Sort">
<th bgcolor="#CCCCCC"> <h5> 100.0 </th>
<th bgcolor="#CCCCCC"> <h5> test3 </th>
<th bgcolor="#CCCCCC"> <h5> </th>
</tr>
<tr id="Stocks">
<th> 55.8 </th>
<th> stock id3 </th>
<td id="Indian-Oil-Corporation-Ltd.">
<a href="www.dalal-street.in/Indian-Oil-Corporation-Ltd">Indian-Oil-Corporation-Ltd.</a>
</td>
</tr>
<tr id="Stocks">
<th> 44.2 </th>
<th> stock id4 </th>
<td id="Power-Finance-Corporation-Ltd.">
<a href="www.dalal-street.in/Power-Finance-Corporation-Ltd">Power-Finance-Corporation-Ltd.</a>
</td>
</tr>
<tr id="titles" value="Disable Sort">
<th bgcolor="#CCCCCC"> <h5> 100.0 </th>
<th bgcolor="#CCCCCC"> <h5> test </th>
<th bgcolor="#CCCCCC"> <h5> </th>
</tr>
<tr id="Stocks">
<th> 55.8 </th>
<th> stock id3 </th>
<td id="Indian-Oil-Corporation-Ltd.">
<a href="www.dalal-street.in/Indian-Oil-Corporation-Ltd">Indian-Oil-Corporation-Ltd.</a>
</td>
</tr>
<tr id="Stocks">
<th> 44.2 </th>
<th> stock id4 </th>
<td id="Power-Finance-Corporation-Ltd.">
<a href="www.dalal-street.in/Power-Finance-Corporation-Ltd">Power-Finance-Corporation-Ltd.</a>
</td>
</tr>
<tr id="titles" value="Disable Sort">
<th bgcolor="#CCCCCC"> <h5> 100.0 </th>
<th bgcolor="#CCCCCC"> <h5> test2 </th>
<th bgcolor="#CCCCCC"> <h5> </th>
</tr>
<tr id="Stocks">
<th> 55.8 </th>
<th> stock id3 </th>
<td id="Indian-Oil-Corporation-Ltd.">
<a href="www.dalal-street.in/Indian-Oil-Corporation-Ltd">Indian-Oil-Corporation-Ltd.</a>
</td>
</tr>
<tr id="Stocks">
<th> 44.2 </th>
<th> stock id4 </th>
<td id="Power-Finance-Corporation-Ltd.">
<a href="www.dalal-street.in/Power-Finance-Corporation-Ltd">Power-Finance-Corporation-Ltd.</a>
</td>
</tr>
这也是:
<table id="portfolios" width="500" border="1" align="center" height="300">
<thead class="colHeaders">
<tr><th class="weight" bgcolor="#999999"><h4> Weight in Motif </h3></th>
<th class="name" bgcolor="#999999"><h4> Segment & Stocks</h3></th>
<th class="price" bgcolor="#999999"><h4> Name of stock </h3></th>
</thead>
<tr id="titles" value="Disable Sort">
<th bgcolor="#CCCCCC"> <h5> 100.0 </th>
<th bgcolor="#CCCCCC"> <h5> test3 </th>
<th bgcolor="#CCCCCC"> <h5> </th>
</tr>
<tr id="Stocks">
<th> 55.8 </th>
<th> stock id3 </th>
<td id="Indian-Oil-Corporation-Ltd.">
<a href="www.dalal-street.in/Indian-Oil-Corporation-Ltd">Indian-Oil-Corporation-Ltd.</a>
</td>
</tr>
<tr id="Stocks">
<th> 44.2 </th>
<th> stock id4 </th>
<td id="Power-Finance-Corporation-Ltd.">
<a href="www.dalal-street.in/Power-Finance-Corporation-Ltd">Power-Finance-Corporation-Ltd.</a>
</td>
</tr>
<tr id="titles" value="Disable Sort">
<th bgcolor="#CCCCCC"> <h5> 100.0 </th>
<th bgcolor="#CCCCCC"> <h5> test </th>
<th bgcolor="#CCCCCC"> <h5> </th>
</tr>
<tr id="Stocks">
<th> 55.8 </th>
<th> stock id3 </th>
<td id="Indian-Oil-Corporation-Ltd.">
<a href="www.dalal-street.in/Indian-Oil-Corporation-Ltd">Indian-Oil-Corporation-Ltd.</a>
</td>
</tr>
<tr id="Stocks">
<th> 44.2 </th>
<th> stock id4 </th>
<td id="Power-Finance-Corporation-Ltd.">
<a href="www.dalal-street.in/Power-Finance-Corporation-Ltd">Power-Finance-Corporation-Ltd.</a>
</td>
</tr>
<tr id="titles" value="Disable Sort">
<th bgcolor="#CCCCCC"> <h5> 100.0 </th>
<th bgcolor="#CCCCCC"> <h5> test2 </th>
<th bgcolor="#CCCCCC"> <h5> </th>
</tr>
<tr id="Stocks">
<th> 55.8 </th>
<th> stock id3 </th>
<td id="Indian-Oil-Corporation-Ltd.">
<a href="www.dalal-street.in/Indian-Oil-Corporation-Ltd">Indian-Oil-Corporation-Ltd.</a>
</td>
</tr>
<tr id="Stocks">
<th> 44.2 </th>
<th> stock id4 </th>
<td id="Power-Finance-Corporation-Ltd.">
<a href="www.dalal-street.in/Power-Finance-Corporation-Ltd">Power-Finance-Corporation-Ltd.</a>
</td>
</tr>
基本上这两个都是从 erb 文件生成的 HTML 代码。现在使用的第一个代码变量是:
h=[ { "folder" => "test3",
"weight" => "100.0",
"stocks" => [{ "id" => "stock id3",
"name" => "Indian Oil Corporation Ltd.",
"weight" => "55.8"},
{ "id" => "stock id4",
"name" => "Power Finance Corporation Ltd.",
"weight" => "44.2" }
]},
{ "folder" => "test",
"weight" => "100.0",
"stocks" => [{ "id" => "stock id3",
"name" => "Indian Oil Corporation Ltd.",
"weight"=> "55.8"},
{"id" => "stock id4",
"name" => "Power Finance Corporation Ltd.",
"weight"=> "44.2"}]
},
{ "folder" => "test2",
"weight" => "100.0",
"stocks" => [{ "id" => "stock id3",
"name" => "Indian Oil Corporation Ltd.",
"weight"=> "55.8"},
{"id" => "stock id4",
"name" => "Power Finance Corporation Ltd.",
"weight"=> "44.2"
}]
}
]
而在我创建的第二个代码中,表是使用拖放更改的,现在我如何获得更新的 h 变量,它将是:
h=[ { "folder" => "test3",
"weight" => "100.0",
"stocks" => [{"id" => "stock id3",
"name" => "Indian Oil Corporation Ltd.",
"weight" => "55.8"},
{"id" => "stock id4",
"name" => "Power Finance Corporation Ltd.",
"weight" => "44.2"},
{"id" => "stock id3",
"name" => "Indian Oil Corporation Ltd.",
"weight" => "55.8"},
{"id" => "stock id4",
"name" => "Power Finance Corporation Ltd.",
"weight" => "44.2"},
{"id" => "stock id3",
"name" => "Indian Oil Corporation Ltd.",
"weight" => "55.8"},
{"id" => "stock id4",
"name" => "Power Finance Corporation Ltd.",
"weight" => "44.2"}]
},
{ "folder" => "test",
"weight" => "100.0",
"stocks" => [],
{ "folder" => "test2",
"weight" => "100.0",
"stocks" => []
}
]
使用 Javascript 或其他东西(APP 是 ruby on rails )。我完全不知道javascript请给出详细解释。