0

从一个简单的 html 页面,用户点击一个按钮,上面写着“添加问题”。

随着那个“点击”,一个 jQuery 对话框会弹出,其中包含一个在原始页面上“隐藏”的表格(显示:无)。

用户在 jQuery 对话框的输入字段中输入一个“数字”(对于那些熟悉医疗代码的人来说,icd-9 代码)。

当用户单击 .dialog 按钮时,会读取、修剪数字并将其发送到 if/else 的第一部分。

如果数字小于 3 个字符,则会在 div 中放置一条消息,显示“这不是有效的 icd-9 代码”。

(如果它是有效的,我会做一个 .ajax 调用来查看是否有相应的 icd-9,如果没有给出消息“No icd-9”或给出 icd-9 代码和 icd-9 文本)

所有第一部分工作正常,除了在发布“错误”消息后,用户立即(我几乎看不到消息 - 我发出警报以停止流程并确认消息在那里)被带回原始 html 页面,而不是 .dialog。

这是有问题的代码:

$("#findbuttonicd9").click(function() {

    varicd9 = document.getElementById('icd9input').value;
    varicd9 = varicd9.trim();

    if (varicd9.length < 3)
       {
        document.getElementById("listicd9").innerHTML = varicd9 + "is not a valid ICD-9 Code";
        return;
       }
         else
       {$.ajax({
                type: "POST",
                url: readicd9backend.php,
                data: {icd9: varicd},
                dataType : 'json', 
                              success: function(result)
                                       {
                                        $("#div1").html("");
                                        if(result.length >= 1)
                                           {
                                            var output = "<table width='500px' class = 'findtable'>";
                                           $.each(result, function(index, value)
                                                 { output += "<tr><td id='icd9' width='50px'>" + value.icd9codedot +
                                                             "</td><td width='250px' style='text-align:left'>" + value.icd9long +
                                                             "</td></tr>";
                                             });
                                         output += "</table>";
                                         $("#listicd9").html(output);
                                     }
                                      else
                                     {$("#listicd9").html("No matches");}
              },
              error : function(e) { ("#listicd9").html('Database access error'); }
            });            
       }
});

我尝试添加一个“retun”(如上所示)并在没有“return”的情况下完成它,它总是让我回到原始的 html 页面。

这个“流量控制”问题对我来说是一个新问题,所以我很感激任何帮助,即使只是一个参考,所以我可以尝试自己解决这个问题。

再次,我非常感谢大家。

编辑:这是点击功能;

$("#addproblementerbutton").click(function() {
 $(function() {  $( "#addproblemtable" ).dialog({
                                                height: 550,
                                                width: 600,
                                                modal: true
                                                });
               });
});

这是整个表格:

<!--start of hidden add problem table-->
<div id="addproblemtable" style="display:none" title="Add a Problem"><!--start of add problem div/table-->
<form id="addproblem">
<table id="addproblem" class="addproblemtable">
  <tr>
    <td style="width:200px; text-align:right;">ICD-9:</td>
    <td><input id="icd9input" type="text"></td>
    <td><button id="findbuttonicd9">FIND ICD-9</button></td>
  </tr>
  <tr>
    <td style="width:200px; text-align:right;">Problem:</td>
    <td><input id="problem" type="text"></td>
    <td><button id="findbuttontext">FIND TEXT</button></td>
  </tr>
  <tr>
    <td colspan="3">
      <div id = "listicd9" style="width:100%; height:200px; overflow-y:scroll; margin-top:10px; margin-bottom:10px; background-color:#F1E2FE">
      </div>
    </td>
  </tr>
  <tr>
    <td style="width:200px; text-align:right;">Date Noted:</td>
    <td><input id="dateonset" type="text"></td>
    <td></td>
  </tr>
  <tr>
    <td style="width:200px; text-align:right;">Date Entered:</td>
    <td><input id="dateentry" type="text"></td>
    <td></td>
  </tr>
  <tr>
    <td colspan="3">
      <input type="radio" id="active" name="status" value="Active" checked="checked" />
      <label class="styleradiobutton"  for="active">Active</label></input>
      <input type="radio" id="inactive" name="status" value="Inactive" />
      <label class="styleradiobutton" for="inactive">Inactive</label></input>
    </td>
  </tr>
  <tr>
    <td colspan="3" style="width:200px; text-align:center;">
      <input id="resetbutton" type="reset" value="RESET" class="formbutton"><!--reset the form-->
      <input id="addproblemsubmitbutton" type="button" value="ADD" class="formbutton"></td>
  </tr><!--add a problem button-->
  <tr>
    <td><div id=listicd9></div></td>
  </tr>
</table>
</form>
</div><!--end of add problem div/table-->

这是您单击以启动 if/else/ajax 的 .dialog 表中的行

  <tr>
    <td style="width:200px; text-align:right;">ICD-9:</td>
    <td><input id="icd9input" type="text"></td>
    <td><button id="findbuttonicd9">FIND ICD-9</button></td>
  </tr>

PS - 我还没有完成 .ajax 调用,因为我无法通过调试中的第一个 if/else。仍在努力。

谢谢!

4

2 回答 2

0

好的,我拿走了你的小提琴并将它分叉以使用更多你原来的 javascript。

这改变了

varicd9 = document.getElementById('testinput').value;
varicd9 = varicd9.trim();

var icd9 = $('#testinput').val();
icd9 = icd9.trim();

还有其他调整可以对出现的控制台错误做出反应。鉴于它是一种抽象,它可能无法完全解决您的问题。

于 2013-09-02T22:45:05.650 回答
0

I found the problem!!!

For a "good reason" (I've forgotten what it was) I put the table in a div. Apparently the table acts differently when it's in a div (even though the div has a different name).

So I took away the div, spiffed up the table a bit and now everything works great!

For me, the learning point was not to enclose things in a div unless it's absolutely necessary.

I thank you all for your comments and help!!

于 2013-09-04T00:24:34.090 回答