According to my usual web development style, all events that do not operate the database directly are implemented by JavaScript as much as possible, so I plan to use js to complete this requirement.
First, let’s analyze the specific situation: this page is an update page, the brand has two fields: Brand 1 and Brand 2, Brand 2 can be empty, and Brand 1 cannot be empty, so the drop-down list box of Brand 2 has more than Brand 1; if any of the first 8 phases of the brand is selected, the "active status" must be hidden, otherwise the default display status of "active status" is "potential"; when the query results have any one of Brand 1 and Brand 2 in the first 8 phases of the brand, the "active status" must also be hidden, otherwise the default display status of "active status" is "potential".
Part of the page
<div name="div_Brand_Baby" style="display: none" runat="server">
<div style="float: left;">Brand 1:</div>
<div style="position: relative; float: left;">
<span style="margin-left: 170px; width: 18px; overflow: hidden;">
<atlas:UpdatePanel ID="UpdatePanel12" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlistFirstConsumeBrand" onchange="ChangeBrand(this)" runat="server"
DataTextField="OptionText" DataValueField="optionValue" DataSourceID="ObjectDataSource11"
Style="width: 188px; margin-left: -170px">
</asp:DropDownList>
</ContentTemplate>
</atlas:UpdatePanel>
</span>
<asp:TextBox ID="txtBrand1" runat="server" onblur="changebrand1(this)" Style="width: 170px;
position: absolute; left: 0px;"></asp:TextBox>
</div>
<div style="float: left;">
Brand 2:</div>
<div style="position: relative; float: left;">
<span style="margin-left: 170px; width: 18px; overflow: hidden;">
<atlas:UpdatePanel ID="UpdatePanel13" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlistSecondConsumeBrand" runat="server" onchange="ChangeBrand(this)"
DataTextField="OptionText" DataValueField="optionValue" DataSourceID="ObjectDataSource12"
Style="width: 188px; margin-left: -170px">
</asp:DropDownList>
</ContentTemplate>
</atlas:UpdatePanel>
</span>
<asp:TextBox ID="txtbrand2" runat="server" onblur="changebrand1(this)" Style="width: 170px;
position: absolute; left: 0px;"></asp:TextBox>
</div>
<asp:ObjectDataSource ID="ObjectDataSource11" runat="server" SelectMethod="RetrieveMilkBrand_Baby"
TypeName="">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="languageID" Type="Int32" />
<asp:Parameter DefaultValue="false" Name="addNull" Type="Boolean" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSource12" runat="server" SelectMethod="RetrieveMilkBrand_Baby"
TypeName="">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="languageID" Type="Int32" />
<asp:Parameter DefaultValue="true" Name="addNull" Type="Boolean" />
<asp:Parameter DefaultValue=" " Name="nullString" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
javascript code
function changebrand1(oTextbox)
{
var brandTag=("ddlistSecondConsumeBrand");
var brand1=("txtbrand1");
var brand2=("txtbrand2");
var brandcolls=;
var textvalue=;
var flag=0;
if(==0)
{
flag=1;
}
else if(>0)
{
for(var i=0;i<;i++)
{
if(oTextbox==brand1 && brandcolls[i].text==textvalue)
{
("ddlistFirstConsumeBrand").=i-1;
flag=1;
ChangeBrand(("ddlistFirstConsumeBrand"));
}
else if(oTextbox==brand2 && brandcolls[i].text==textvalue)
{
=i;
flag=1;
ChangeBrand(brandTag);
}
}
if(flag==0)
{
alert("Enter brand error!");
="";
();
}
}
}
function ChangeBrand(me){
var brand1ID = ;
var brand2ID = ;
var brandvalue1=("txtbrand1");
var brandvalue2=("txtbrand2");
if((brand1ID=="10")&&(brand2ID=="-1"))
{
=9;
}
for(var i=0;i<("ddlistSecondConsumeBrand").;i++)
{
if(("ddlistFirstConsumeBrand") == me && ==i)
{
=("ddlistFirstConsumeBrand").options[i].text;
}
if(("ddlistSecondConsumeBrand") == me && ==i)
{
=("ddlistSecondConsumeBrand").options[i].text;
}
if(i<8 && ("ddlistFirstConsumeBrand") == me && ==i)
{
.="block";
.="none";
.="none";
("ddlistPotential").options[0].selected="selected";
break;
}
else if(i>0 && i<9 && ("ddlistSecondConsumeBrand") == me && ==i)
{
.="block";
.="none";
.="none";
("ddlistPotential").options[0].selected="selected";
break;
}
else if(i>8)
{
.="none";
.="block";
.="block";
("ddlistPotential").options[1].selected="selected";
}
}
}
First, let’s analyze the specific situation: this page is an update page, the brand has two fields: Brand 1 and Brand 2, Brand 2 can be empty, and Brand 1 cannot be empty, so the drop-down list box of Brand 2 has more than Brand 1; if any of the first 8 phases of the brand is selected, the "active status" must be hidden, otherwise the default display status of "active status" is "potential"; when the query results have any one of Brand 1 and Brand 2 in the first 8 phases of the brand, the "active status" must also be hidden, otherwise the default display status of "active status" is "potential".
Part of the page
Copy the codeThe code is as follows:
<div name="div_Brand_Baby" style="display: none" runat="server">
<div style="float: left;">Brand 1:</div>
<div style="position: relative; float: left;">
<span style="margin-left: 170px; width: 18px; overflow: hidden;">
<atlas:UpdatePanel ID="UpdatePanel12" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlistFirstConsumeBrand" onchange="ChangeBrand(this)" runat="server"
DataTextField="OptionText" DataValueField="optionValue" DataSourceID="ObjectDataSource11"
Style="width: 188px; margin-left: -170px">
</asp:DropDownList>
</ContentTemplate>
</atlas:UpdatePanel>
</span>
<asp:TextBox ID="txtBrand1" runat="server" onblur="changebrand1(this)" Style="width: 170px;
position: absolute; left: 0px;"></asp:TextBox>
</div>
<div style="float: left;">
Brand 2:</div>
<div style="position: relative; float: left;">
<span style="margin-left: 170px; width: 18px; overflow: hidden;">
<atlas:UpdatePanel ID="UpdatePanel13" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlistSecondConsumeBrand" runat="server" onchange="ChangeBrand(this)"
DataTextField="OptionText" DataValueField="optionValue" DataSourceID="ObjectDataSource12"
Style="width: 188px; margin-left: -170px">
</asp:DropDownList>
</ContentTemplate>
</atlas:UpdatePanel>
</span>
<asp:TextBox ID="txtbrand2" runat="server" onblur="changebrand1(this)" Style="width: 170px;
position: absolute; left: 0px;"></asp:TextBox>
</div>
<asp:ObjectDataSource ID="ObjectDataSource11" runat="server" SelectMethod="RetrieveMilkBrand_Baby"
TypeName="">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="languageID" Type="Int32" />
<asp:Parameter DefaultValue="false" Name="addNull" Type="Boolean" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSource12" runat="server" SelectMethod="RetrieveMilkBrand_Baby"
TypeName="">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="languageID" Type="Int32" />
<asp:Parameter DefaultValue="true" Name="addNull" Type="Boolean" />
<asp:Parameter DefaultValue=" " Name="nullString" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
javascript code
Copy the codeThe code is as follows:
function changebrand1(oTextbox)
{
var brandTag=("ddlistSecondConsumeBrand");
var brand1=("txtbrand1");
var brand2=("txtbrand2");
var brandcolls=;
var textvalue=;
var flag=0;
if(==0)
{
flag=1;
}
else if(>0)
{
for(var i=0;i<;i++)
{
if(oTextbox==brand1 && brandcolls[i].text==textvalue)
{
("ddlistFirstConsumeBrand").=i-1;
flag=1;
ChangeBrand(("ddlistFirstConsumeBrand"));
}
else if(oTextbox==brand2 && brandcolls[i].text==textvalue)
{
=i;
flag=1;
ChangeBrand(brandTag);
}
}
if(flag==0)
{
alert("Enter brand error!");
="";
();
}
}
}
function ChangeBrand(me){
var brand1ID = ;
var brand2ID = ;
var brandvalue1=("txtbrand1");
var brandvalue2=("txtbrand2");
if((brand1ID=="10")&&(brand2ID=="-1"))
{
=9;
}
for(var i=0;i<("ddlistSecondConsumeBrand").;i++)
{
if(("ddlistFirstConsumeBrand") == me && ==i)
{
=("ddlistFirstConsumeBrand").options[i].text;
}
if(("ddlistSecondConsumeBrand") == me && ==i)
{
=("ddlistSecondConsumeBrand").options[i].text;
}
if(i<8 && ("ddlistFirstConsumeBrand") == me && ==i)
{
.="block";
.="none";
.="none";
("ddlistPotential").options[0].selected="selected";
break;
}
else if(i>0 && i<9 && ("ddlistSecondConsumeBrand") == me && ==i)
{
.="block";
.="none";
.="none";
("ddlistPotential").options[0].selected="selected";
break;
}
else if(i>8)
{
.="none";
.="block";
.="block";
("ddlistPotential").options[1].selected="selected";
}
}
}