dtq26360 2016-09-18 01:52
浏览 28
已采纳

使用ajax检索记录并在php中显示它们

I currently have a webpage that works great. I select my load number and a ajax query gets the information and puts the results in textboxs. The page is split, one part displays information, but when "print" is selected, it formats the results to print a bubble sheet.

Here is the problem. Instead of displaying the "On Screen" results in textboxs, I would rather just display as normal text.

The active page is located at this address

The retrieval code is quite long, here is a sample.

<script>

  $(document).ready(function(){ /* PREPARE THE SCRIPT */

    $("#loads").change(function(){ /* TRIGGER THIS WHEN USER HAS SELECTED DATA FROM THE SELECT FIELD */

      var loadnumber = $(this).val(); /* STORE THE SELECTED LOAD NUMBER TO THIS VARIABLE */

      $.ajax({ /* START AJAX */

        type: "POST", /* METHOD TO USE TO PASS THE DATA */
        url: "actionprt.php", /* THE FILE WHERE WE WILL PASS THE DATA */
        data: {"loadnumber": loadnumber}, /* THE DATA WE WILL PASS TO action.php */
        dataType: 'json', /* DATA TYPE THAT WILL BE RETURNED FROM action.php */
        success: function(result){
          /* PUT CORRESPONDING RETURNED DATA FROM action.php TO THESE TEXTBOXES */
    for (i = 1; i < 14; i++) { 
        $("#prtDescription" + i).val("");
        $("#prtMethod" + i).val("");
        $("#prtPONumber" + i).val("");
        $("#prtGallons" + i).val("");
        $("#prtAmount" + i).val("");
    } 

      $("#NumberStops").val(result.NumberStops);
      $("#ShipperName").val(result.CustomerName);
      $("#prtship").val(result.CustomerName);
      $("#ShipperAddr1").val(result.CustomerAddress);
      $("#ShipperAddr2").val(result.CustomerAddress2);
      $("#ShipperCity").val(result.CustomerCity);
      $("#prtshipcity").val(result.CustomerCity);
      $("#ShipperState").val(result.CustomerState);
      $("#prtshipstate").val(result.CustomerState);
      $Phone = result.CustomerPhone
  $Phone = '(' + $Phone.substring(0,3) + ') ' + $Phone.substring(3,6) + '-' + $Phone.substring(6,10)
      $("#ShipperPhone").val(result.CustomerPhone);
      $("#ShipperContact").val(result.CustomerContact);
      $("#PickupDate").val(result.PickupDate);
      $("#prtdate").val(result.PickupDate);
      $("#PickupTime").val(result.PickupTime);
      $("#CustomerPO").val(result.CustomerPO);
      $("#Weight").val(result.Weight);
      $("#prtweight").val(result.Weight);
      $("#Pieces").val(result.Pieces);
      $("#prtpieces").val(result.Pieces);
      $("#BLNumber").val(result.BLNumber);
      $("#prtbol").val(result.BLNumber);
      $("#TrailerNumber").val(result.TrailerNumber);
      $("#prttrailer").val(result.TrailerNumber);

...

I tried document.write() but that cleared the page which is not what I am looking for. I want to keep my images and combobox selection box on the page so I can select other loads when needed rather then just one at a time.

Please help.... If you require more information to answer the question, please ask and I will post.

  • 写回答

2条回答 默认 最新

  • dsavz66262 2016-09-18 02:07
    关注

    Why not just make a new div after your load selection and simply append all those results into it?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化