Link to home
Start Free TrialLog in
Avatar of luubi
luubiFlag for United States of America

asked on

Listbox javascript selectindex

hi every one,

Can someone help me with Javascript codes?  I have a databound listbox. I would like to do a javascript so that when user click on an item, it will pass that item value to a gridview.  I don't want to do Autopostback with my listbox because it create problem with my Listsearch_Extender

Thank you so much
*** added .NET and pushed the request attention link *** mplungjan, ee ZAPE

Open in new window

Avatar of MogalManic
MogalManic
Flag of United States of America image

Do you mean something like this:


<asp:ListBox ID="ListBox1" runat="server" >
  <asp:ListItem>a</asp:ListItem>
  <asp:ListItem>b</asp:ListItem>
  <asp:ListItem>c</asp:ListItem>
</asp:ListBox>
Add a javascript function
 function Selection()
{
  alert(List.options[List.selectedIndex].value);
}
Then in code behind ,  
 
ListBox1.Attributes.Add("onchange", "Selection(this);");

Open in new window

but I don't know what you mean by "pass that item value to a gridview"
Avatar of luubi

ASKER

I have a listbox databound listing of all the Project #.  Then, when a user click on the Project #, it will pass the value to a gridview to view all the tasks available for that Project.

I would like to do this with JS script instead of Auto Postback because when I turn on AutoPostback for listbox, my listsearch_extender does not work

Thanks
ASKER CERTIFIED SOLUTION
Avatar of luubi
luubi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial