1

こんにちは、JSPページに行レベルで更新ボタンのあるテーブルがあります。更新ボタンをクリックすると、データベースがチェックされ、これらの2つの列が取得され、古い値が置き換えられます。つまり、更新します。

これは私のjspページです。

<script src="js/jquery1.min.js"></script>
<script
<script type="text/javascript">
function refreshRecord(id)
{
  $(document).ready(function(){
  $("#buto").click(function(){
  $(this).parents('tr').find(".b1").load(".b1");
  $(this).parents('tr').find(".b2").load(".b2");
  alert("value");
  });
  });
}
  <table border="1" class="displaytab" id="rtable">
   <tr> 
   <th>#Records</th><th>Status</th><th>Estimated Time</th><th></th>
   </tr>

   <s:iterator value="uploadList" var="m"> 
            <tr>   
            <td class="b1"><s:property value="%{#m.numRecords}" /></td>
            <td class="b2"><s:property value="%{#m.status}" /></td>
            <td>tbd</td>

            <td><s:property value="%{#m.numRecords}" /></td>
            <td><a href=""><img src="images/generate.png" title="Generate Report"</a></td>
            <td><a href=""><img src="images/refresh.png" title="Refresh" id="buto"    onclick="refreshRecord(<s:property value="%{#m.fileId}" />);"></a></td>
            </tr>
         </s:iterator>
         </table>

事前に感謝します

4

3 に答える 3

0

ajaxを使う必要があると思います。

以下に 2 つの例を示します 。 http://www.tutorialspoint.com/ajax/ajax_database.htm http://www.ggkf.com/ajax/onclick-update-with-autosuggestion

于 2013-09-24T13:57:16.780 に答える
0

簡単な HTML で ajax がどのように機能するかを学びましょう... これを学べば、アプリケーションに同じものを簡単に実装できます

この HTML をフォルダー [たとえば ajaxFolder] に保存します。

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $.ajax({
        url:"somePath/testMe.txt", //pls specify correct path of text file and enter something in the file.
        success:function(result){$("#div1").html(result);},
        error:function(result){$("#div1").html("It was a fuilure !!!");}
    });
  });
});
</script>
</head>
<body>

<div id="div1"><h2>Click the button. Ajax will take data from the text file and will show you here.</h2></div>
<button>Get External Content</button>

</body>
</html>

somePath/testMe.txt をどこかに保存し、そこにデータを入力します。

于 2013-09-25T09:23:10.663 に答える