日期:2014-05-17  浏览次数:20664 次

求帮忙写一个数字即时加减的功能并用POST发送
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="all_cont">

  <tr>
  <th width="100"><strong>序号</strong></th>
  <th><strong>+ 利息 -</strong></th>
  <th>
  <strong>自定义调节幅度</strong>
  <select name="aa">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="5">5</option>
  <option value="10">10</option>
  <option value="20">20</option>
  <option selected="selected" value="0.5">默认</option>
  </th>
  </tr>
  
  <tr>
  <td align="center">1</td>
  <td align="center">99.50</td>
  </tr>
  
  <tr>
  <td align="center">2</td>
  <td align="center">88.50</td>
  </tr>
  
  <tr>
  <td align="center">3</td>
  <td align="center">77.50</td>
  </tr>
  
  <tr>
  <td align="center">4</td>
  <td align="center">66.50</td>
  </tr>
  
  <tr>
  <td align="center">5</td>
  <td align="center">55.50</td>
  </tr>
  
</table>


如上的这段代码,其中,点击“利息“旁边“+”号或”-“的时候,下面的所有数字都会相应的增加或减少默认的0.5,也可以按照旁边选择框调节幅度。同时,用post方式发送到post.php文件中。
怎么实现呢?
------解决方案--------------------
给+ - 绑定click事件,事件中ajax请求,成功修改数字,否则提示失败
------解决方案--------------------
参考这个写写:
//$.post()方式:
$('#test_post').click(function (){
    $.post(
      'ajax_json.php',
      {
        username:$('#input1').val(),
        age:$('#input2').val(),
        sex:$('#input3').val(),
        job:$('#input4').val()
      },
      function (data) //回传函数
      {
        var myjson='';
        eval_r('myjson=' + data + ';');
        $('#result').html("姓名:" + myjson.username + "<br/>工作:" + myjson['job']);
      }
    );
   });