English 中文(简体)
1. 根据减少盒子甄选办法提出的修改表
原标题:Change table based on dropdown box selection

我需要能够根据所选择的菜单下降项目显示表的变化。 我不知道用javascript写什么。 我迄今为止的法典是:

JS:

//change table viewed

$("#view").change( function (event) {
$.getJSON( view.php?view=  + $(this).val(), function (json) { 


});
});

传真:

                <div>
                View: <select id="view"><option value="failed">Failed</option><option value="pending">Pending</option><option value="both">Both</option></select>
                <table id="jobs-failed" border="1">
                <tr><th>ID</th><th>Media</th><th>Playlist</th><th>Input</th><th>Output</th><th>Bit Rate</th><th>Status</th><th>Encoder</th><th>Progress</th></tr>
                <tr><td>2851</td><td>1849474</td><td>367</td><td>txt</td><td>html</td><td>best</td><td>failed</td><td>encvm2</td><td>NULL</td></tr>
                </table>
                <table id="jobs-pending" border="1">
                <tr><th>ID</th><th>Media</th><th>Playlist</th><th>Input</th><th>Output</th><th>Bit Rate</th><th>Status</th><th>Encoder</th><th>Progress</th></tr>
                <tr><td>2344</td><td>1843278</td><td>455</td><td>mp3</td><td>wav</td><td>best</td><td>pending</td><td>encvm1</td><td>NULL</td></tr>
                </table>
                <table id="jobs-both" border="1">
                <tr><th>ID</th><th>Media</th><th>Playlist</th><th>Input</th><th>Output</th><th>Bit Rate</th><th>Status</th><th>Encoder</th><th>Progress</th></tr>
                <tr><td>2851</td><td>1849474</td><td>367</td><td>txt</td><td>html</td><td>best</td><td>failed</td><td>encvm2</td><td>NULL</td></tr>
                <tr><td>2344</td><td>1843278</td><td>455</td><td>mp3</td><td>wav</td><td>best</td><td>pending</td><td>encvm1</td><td>NULL</td></tr>
                </table>
                </div>

感谢!

最佳回答

这感觉像“我如何规划”问题(而不是“我如何解决这一具体的方案拟定问题”),因此,我大米将是一个小小的 ter,但......。

$("#view").change( function (event) {

你们就是这样。

$.getJSON( view.php?view=  + $(this).val(), function (json) {

正如乔杜里指出的,除非你正在使用非洲复兴开发银行,否则这种做法是错误的。 根据在座各位在座谈中的评论,我会认为情况并非如此。 你们有一些内容准备在网页上已经播放。 在这种情形下,打捞方式是简单的:

function doSwap(id) {
  // This is just one way of doing the swap; see jQuery Manipulation docs for others
  var content = $("#" + id).html();
  $("table#jobs-failed").html(content);
  // repeat for your other tables
}
$("#view").change( function (event) {
  var $target = $(event.target);
  var whatTheySelected = $target.val();
  if (whatTheySelected == case1) {
    doSwap("content1");
  } else if (whatTheySelected == case2) ...

如果你没有内容(你只是有数据或数据中的统计变量),那么,你就需要做这些内容。 不这样做:

  var content = $("#" + id).html();

确实:

  var content = $("<tr><td>" + yourVar + "</td><td>" + yourVar2 +"</td></tr>");

希望会有所帮助。

问题回答

您是不是向JSON客户提供表格吗? 否则,你们需要改变这一活动,以便:

$( #id_of_some_table_wrapper ).load( view.php?view=  + $(this).val());




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签