簡體   English   中英

show div取決於在文本框中輸入的數字,然后單擊按鈕

[英]show div depends on the number entered in textbox and a button click

我有jQuery對話框,如果用戶單擊#buttonDialog對話框將出現,並且將要求他們提供其住所的地址和人數。 我的問題是,如果用戶在#textHouseOccupant輸入數字, #textHouseOccupant #divOccupantProfile將顯示取決於在#textHouseOccupant輸入的#textHouseOccupant 例如,用戶在#textHouseOccupant輸入5並單擊#btnAddOccupant按鈕,將顯示5 #divOccupantProfile

jQuery對話框

<table>
<tr>
  <td><div id="divresident" runat="server" visible="false">
  <table style="margin-top:10px; margin-bottom:10px">
  <tr>
    <td width="300" style="text-align:left"><asp:Label ID="lbAddress" runat="server" Text="Address"></asp:Label></td>
    <td width="300"><asp:TextBox ID="txtAddress" class="basetxt" runat="server" Width="290"></asp:TextBox></td>
  </tr>
  <tr>
    <td style="text-align:left"><asp:Label ID="lbHouseOccupant" runat="server" Text="Number of House occupant"></asp:Label></td>
    <td><asp:TextBox ID="txtHouseOccupant" class="basetxt" runat="server" Width="290"></asp:TextBox></td>
   </tr>
   <tr>
     <td style="text-align:left"><asp:Button ID="btnAddOccupant" runat="server" Text="+" />
     <asp:Label ID="lbAddOccupant" runat="server" Text="Add Occupant"></asp:Label></td>
   </tr>
   <tr>
     <td>
     <div id="divShowFormHere"></div>
     </td>
   </tr>
   </table>
   </div></td>
 </tr>
 </table>

#divOccupantProfile

<div id="divOccupantProfile">

<asp:Label ID="OPfamilyname" runat="server" Text="Family Name"></asp:Label>
<asp:TextBox ID="textOPfamilyname" runat="server"></asp:TextBox><br />

<asp:Label ID="OPfirstname" runat="server" Text="First Name"></asp:Label>
<asp:TextBox ID="textOPfirstname" runat="server"></asp:TextBox><br />

<asp:Label ID="OPmiddlename" runat="server" Text="Middle Name"></asp:Label>
<asp:TextBox ID="textOPmiddlename" runat="server"></asp:TextBox><br />

<asp:Label ID="OPmaritalstatus" runat="server" Text="Marital Status"></asp:Label>
<asp:DropDownList ID="ddlOPmaritalstatus" runat="server" >
    <asp:ListItem></asp:ListItem>
    <asp:ListItem>Married</asp:ListItem>
    <asp:ListItem>Single</asp:ListItem>
    <asp:ListItem>Divorced</asp:ListItem>
</asp:DropDownList><br />

<asp:Label ID="OPoccupation" runat="server" Text="Occupation"></asp:Label>
<asp:TextBox ID="textOPoccupation" runat="server"></asp:TextBox><br />

<asp:Label ID="OPrelationship" runat="server" Text="Relationship"></asp:Label>
<asp:DropDownList ID="ddlOPrelationship" runat="server" >
    <asp:ListItem></asp:ListItem>
    <asp:ListItem>Wife</asp:ListItem>
    <asp:ListItem>Daughter</asp:ListItem>
    <asp:ListItem>Son</asp:ListItem>
    <asp:ListItem>Father</asp:ListItem>
    <asp:ListItem>Mother</asp:ListItem>
    <asp:ListItem>House helper</asp:ListItem>
    <asp:ListItem>Driver</asp:ListItem>
</asp:DropDownList>

</div>

就個人而言,我會以不同的方式處理這種情況。 我通常有一個按鈕/圖標,用於添加其他人。 Asp.NET MVC可以更輕松地處理這些情況,但是在Web Forms中,此鏈接顯示了如何進行操作,其竅門是使ViewState能夠記住添加的每個新控件,否則任何回發操作都將刪除它們:

http://www.codeproject.com/Articles/502251/How-to-create-controls-dynamically-in-ASP-NET-和

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM