option>choose something /option> /select> and I have this javascript function" />
开发者

change option of <select> Dynamically with javascript and read it on asp.net

开发者 https://www.devze.com 2023-03-20 21:25 出处:网络
I have :selectid=\"select1\" runat=\"server\"> option>choose something /option> /select> and I have this javascript function

I have : select id="select1" runat="server"> option>choose something /option> /select>

and I have this javascript function

var op = document.getElementById("select1");

for (i = 0; i < array.length - 1; i++) {
    op.options[i] = new Option(arr[i]);  
}

now after this function, the select has more <option>.

Now When pressing on asp:button, I want to be able to read(on server side) the new selected value.

unfortunately when the server process the page ,all the selcet1 values开发者_Go百科 that was given by the javascript function are gone and the server always see the orignal value of the select1 ("choose something").

so, I can I read, on server side, the new options of the select1, that was generte by the javascript ?

Thanks for any help

Baaroz


You can loop the values by finding it using Request.Form, like

foreach(string key in Request.Form) {
    Response.Write(key + ": " + Request.Form[key] + "<br />");
}

You might also just find it by using Request.Form["select1"];

0

精彩评论

暂无评论...
验证码 换一张
取 消