English 中文(简体)
如何能动态地改变退款清单的某些价值
原标题:how can i change selected value of drop list dynamically

i 想从文字箱中提取价值,然后根据这一价值改变下降名单的价值。

<html>
    <head>
        <script>
            function change()
            {
                var value = document.getElementById( text ).value;
                document.getElementById("Model").selectedvalue = value
            }
        </script>
    </head>
    <body>
        <asp:DropDownList ID="Model" AutoPostBack="false" runat="server" CssClass="styled">
            <asp:ListItem Value="None">None</asp:ListItem>
            <asp:ListItem Value="Enum">Enum</asp:ListItem>
            <asp:ListItem Value="Sum">Sum</asp:ListItem>
            <asp:ListItem Value="Multi">Multi</asp:ListItem>
            <asp:ListItem Value="Xaxis">Xaxis</asp:ListItem>
        </asp:DropDownList>
        <input id="text" type="text"/>
        <input type="button" onclick="change();"/>
    </body>
<html>
问题回答

可帮助您

你们可以很容易地利用以下代码进行分类。

 function change()
    {
      $("#Model option[value= "+ $( #text ).val()+" ]").attr( selected ,  selected );    
     }

您需要修改以下文件:document.getElementById(“Model”).s selected Value=valye to document.getElementById(“<% = 模型.ClientID %>”options. Value=valye

your code will never find the Model, if you are using .NET 4 you can add

CLientIdMode="Static" 

页: 1

<asp:DropDownList ID="Model" AutoPostBack="false" runat="server" ClientIdMode="Static" CssClass="styled">
        <asp:ListItem Value="None">None</asp:ListItem>
        <asp:ListItem Value="Enum">Enum</asp:ListItem>
        <asp:ListItem Value="Sum">Sum</asp:ListItem>
        <asp:ListItem Value="Multi">Multi</asp:ListItem>
        <asp:ListItem Value="Xaxis">Xaxis</asp:ListItem>
    </asp:DropDownList>

......

document.getElementById("Model").selectedvalue = value

现在将找到控制权。

您必须写:

document.getElementById("Model").value = value;

不是你的职责:

document.getElementById("Model").selectedvalue = value;

More over if you are using master page @hungryMind answer is also correct, because in javascript there is .value not .selectedvalue.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!