Show Div取决于文本框中输入的编号和单击按钮



我有jQuery对话框,如果用户单击#buttonDialog对话框,则会出现,他们将被要求提供其房屋居住者的地址和数量。我的问题是,如果用户输入#textHouseOccupant #divOccupantProfile中的数字将取决于#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表单中,这里有一个链接向您展示了如何做到这一点,诀窍是使ViewState记住您添加的每个新控件,否则任何帖子都会删除它们:

http://www.codeproject.com/articles/502251/how-to-to-create-controls-dynamcy-in-asp-net-and-and-and-and-and-ant-an-

最新更新