Php和jquery动态显示和隐藏div

时间:2012-06-27 15:15:03

标签: php jquery mysql

I have a list of the conditions and i fetch their name and it works fine but i want when i click the condition name it description come below.

i have done that but it shows for only one can you help me for that

这是html代码,我用它来显示记录的描述,它总是显示最后一条记录。 当我添加记录时,添加意味着可以正常添加 它也适用于编辑也适用于删除 但是如果有两个记录则每次显示最后一条记录的描述而不是我点击的记录 我想要显示已记录的记录的描述     感谢

    <div>
    <?php
     $query="select * from tbl_coditions where userId=".$_SESSION['userId'];
     $result=mysql_query($query) or die(mysql_error());
     while($row=mysql_fetch_array($result))
    {
     $VisitDate=strtotime($row['DiagnosisDate']);
     $VisitDate=date("m-d-Y",$VisitDate);
     $userId=$row['userid'];
     $conditionId=$row['conditionId'];
    ?>
     <script>
     $(document).ready(function(){
     $("a#p<?php if(isset($conditionId)) echo $conditionId; ?>").click(function(event){
     $("#HiddenDiv<?php if(isset($conditionId)) echo $conditionId; ?>").show();
     })    
     });
    </script>

<div id="AjaxDiv1">      

                              <div id="HiddenDiv<?php if(isset($conditionId)) echo $conditionId?>" style="display:none;">
                              <?php 
                              $query="select * from tbl_coditions where conditionId=$conditionId";
                              $result=mysql_query($query) or die(mysql_error());
                              $query_result=mysql_fetch_array($result); 
                              $VisitDate=strtotime($query_result['DiagnosisDate']);
                              $VisitDate=date("m-d-Y",$VisitDate);                    
                              ?>
                              <div class="detailContainer panelContent">
  <div class="panelTitle" tabindex="-1">
    <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_Name_Row_RowContainer" class="detailRowContainer">
      <div class="detailRow">
        <div class="detailLeftColumn mxDetailsLabel"> Condition:
          <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_Name_Row_ValidatorContainer" class="detailErrorContainer"></div>
        </div>
        <div class="detailRightColumn"> <span id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_Name_Row_ViewControl"><?php echo $query_result['ServiceName']; ?></span> </div>
      </div>
    </div>
  </div>
  <div class="detailContent">
    <div class="narrowTopContent">
      <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_DiagnosisDate_Row_RowContainer" class="detailRowContainer detailRowOdd">
        <div class="detailRow">
          <div class="detailLeftColumn mxDetailsLabel"> Diagnosis Date:
            <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_DiagnosisDate_Row_ValidatorContainer" class="detailErrorContainer"></div>
          </div>
          <div class="detailRightColumn"> <span id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_DiagnosisDate_Row_ViewControl"><?php echo $VisitDate;  ?></span> </div>
        </div>
      </div>
      <div>
        <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_InnerUpdatePanel">
          <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_DateOfServiceSelection_Row_RowContainer" class="detailRowContainer">
            <div class="detailRow">
              <div class="detailLeftColumn mxDetailsLabel"> Date of Service:
                <div class="detailErrorContainer"></div>
              </div>
              <div class="detailRightColumn">
                <?php 
                $VisitDate=strtotime($query_result['DateofService']);
                echo $VisitDate=date("m-d-Y",$VisitDate);                     
                 ?>

              </div>
            </div>
          </div>
          <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_InformationSource_RowContainer" class="detailRowContainer detailRowOdd">
            <div class="detailRow">
              <label>
              <div class="detailLeftColumn mxDetailsLabel"> Information Source:
                <div class="detailErrorContainer"></div>
              </div>
              <div class="detailRightColumn"> <span id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_InformationSource_SourceNameLabel">User Entered</span> </div>
              </label>
            </div>
          </div>
          <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_DiagnosingProvider_Row_RowContainer" class="detailRowContainer">
            <div class="detailRow">
              <div class="detailLeftColumn mxDetailsLabel"> Provider or Facility:
                <div class="detailErrorContainer"></div>
              </div>
              <div class="detailRightColumn"> <span><?php echo $query_result['Provider']; ?></span> </div>
            </div>
          </div>
          <div class="notesSection">
            <div class="commentRow">
              <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_Comment_Row_RowContainer" class="detailRowContainer">
                <div class="detailRow">
                  <div class="detailLeftColumn mxDetailsLabel"> Notes:
                    <div class="detailErrorContainer"></div>
                  </div>
                  <div class="detailRightColumn"> <span><?php echo $query_result['Notes'] ?></span> </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="YesNoSection">
      <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_IsShared_YesNoRow_RowContainer">
        <div class="detailRow">
          <fieldset>
            <legend class="detailLeftColumn mxDetailsLabel"> <span>Hide this item when printing or when sharing with a health care provider?</span> </legend>
            <div style="clear:both;"></div>
            <div class="detailRightFieldsetColumn">
              <div style="display: block; margin-top: 2px;"> <span class="detailRightColumn">
                <div class="detailRightColumn">
                  <div><?php  echo $query_result['HideItem'];?></div>
                </div>
                </span> </div>
            </div>


          </fieldset>
        </div>
      </div>
      <div>
        <div class="detailRow">
          <fieldset>
            <legend class="detailLeftColumn mxDetailsLabel"> <span>Do you still have this condition?</span> </legend>
            <div style="clear:both;"></div>
            <div class="detailRightFieldsetColumn">
              <div style="display: block; margin-top: 2px;"> <span class="detailRightColumn">
                <div class="detailRightColumn">
                  <div><?php  echo $query_result['stillCondition'];?></div>
                </div>
                </span> </div>
            </div>
            <div class="detailErrorContainer"> </div>
            <span class="question_mark"></span>
          </fieldset>
        </div>
      </div>
    </div>
  </div>
  <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_ctl01">
    <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_EntryRightSideContainer" class="EntryRightSideContainer">
      <div class="LearnMoreDetail">
        <div class="mxRoundTable">
          <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_LearnMore_Container_headerDiv" class="mxRoundTableTitle">
            <div class="mxRoundedCap"></div>
          </div>
          <div class="mxDataTableBackground">
            <div class="mxRoundedCap">
              <div class="mxRoundedMain">
                <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_LearnMore_Container_titleDiv" class="mxDataTableTitle">
                  <h2>
                    <div class="LearnMoreDetailTitle">
                      <h2>Learn More About Diabetes Mellitus</h2>
                    </div>
                  </h2>
                </div>
                <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_LearnMore_Container_ContentDiv" class="mxDataTableContent">
                  <div class="LearnMoreDetailText">
                    <ul>
                      <li>
                        <div id="learnMoreItem"> <img id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_LearnMore_Container_LinkRepeater_ctl00_Icon" src="images/content.png" alt="" style="border-width: 0px;"> <a id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_LearnMore_Container_LinkRepeater_ctl00_Link" href="javascript:PopupMultiViewer('/common/content/contentviewer.aspx%3fcui=C0011849%26topic=Diabetes+Mellitus%26etype=%26subtypes=%26contid=XIe3090mJjlQCAfxu90R%26toplink=%26topid=0%26topsrcid=0')">Articles related to Diabetes Mellitus</a>
                          <div style="clear: both;"></div>
                        </div>
                      </li>
                    </ul>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="mxRoundTableFooter">
            <div class="mxRoundedCap"></div>
          </div>
        </div>
      </div>
    </div>
    <div  class="Pan" style="width: 650px; display: none; position: fixed; z-index: 100001; left: 631.5px; top: 447.5px;">
      <div class="mxModalContainer" id="ModalContainer">
        <div  class="mxHeader">
          <div>
            <div class="mxModalContentTitle">
              <h1></h1>
            </div>
          </div>
          <div class="mxModalContentTitleClose"> </div>
          <div>
            <div class="mxModalContentTitleAdditional"> </div>
          </div>
        </div>
              </div>
    </div>    
    <div class="modalBackground" style="display: none; position: fixed; left: 0px; top: 0px; z-index: 10000; width: 1263px; height: 994px;" id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_ctl05_ModalDialogExtender_backgroundElement"></div>
  </div>
  <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_CommandRow_DetailButtonRow" class="detailRow detailButtonRow"> &nbsp;
    <div id="ctl00_ctl00_ctl00_Content_LobbyContent_Content_EntryRepeater_ctl00_InterfaceControl_DetailAnimator_ctl03_CommandRow_DetailButtonContainer"><script type="text/javascript">
jQuery(document).ready(function(){  
        $("#button").click( function(){
            var optionValue = <?php echo $conditionId ?>;
            var categoryval=1;
            jQuery.ajax({
            type: "GET",
            url: "getcondition.php",
            data: "category="+optionValue+"&categoryval="+categoryval,
            success: function(response){
                    jQuery("#AjaxDiv").html(response);
                    jQuery("#AjaxDiv").show();
                    jQuery("#AjaxDiv1").hide();                 
                }
            });          
        });
    });
</script>
      <div class="mxButtonOrange"> <span>
        <button class="mxClearButtonOrange" id="button" type="button"  name="button">Edit</button>
        </span> </div>
      <div class="mxButtonOrange"> <span>


      <script type="text/javascript">
jQuery(document).ready(function(){  
        $("#button1").click( function(){
            var optionValue = <?php echo $conditionId ?>;
            var categoryval=1;
            jQuery.ajax({
            type: "GET",
            url: "deletecondition.php",
            data: "category="+optionValue+"&categoryval="+categoryval,
            success: function(response){
                    jQuery("#AjaxDiv").html(response);
                    jQuery("#AjaxDiv").show();
                    jQuery("#AjaxDiv1").hide();                 
                }
            });          
        });
    });
</script>
        <button class="mxClearButtonOrange" type="button" id="button1"  value="Delete" >Delete</button>
        </span> </div>

    </div>
  </div>
</div>











                              </div>
                        </div>`enter code here`

0 个答案:

没有答案