View Single Post
  #1 (permalink)  
Old March 10th, 2008, 04:25 AM
vishnu108mishra vishnu108mishra is offline
Authorized User
Join Date: Nov 2007
Location: Allahabad, UP, India.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can I set TextBox value from Listbox,

How can I set TextBox value from Listbox, because I popuplate Listbox through java script..
I tried it by calling the java script function onChange(and onSelectedIndexChange) event of list box, but event is not calling java script function

from here..

following is my code--

<div id="helptypediv" style="visibility: hidden; z-index:1">
                            <asp:ListBox ID="lstShowHistory" SelectionMode="Single" runat="server" Width="200px" Height="300px"


function setTextBoxValue(e)
            //var strListBoxName = document.getElementById('lstShowHistory');
            document.getElementById('txtUrlLink').value = e ; //strListBoxName.options[strListBoxName.selectedIndex].text ;

//;options[document.getElementById('lstShowHistory').selected Index].text;

the list box is popuplate on mouse over event on the text box...

txtUrlLink.Attributes.Add("onfocus", "ShowList();");

function ShowList()
   document.getElementById('helptypediv').style.visib ility='visible';return false;

function getCookie()
        var strListBox = document.getElementById('lstShowHistory');
        var ls1= document.cookie.split("=");
        if (ls1.length >1)
            var ls2 = ls1[1].split("|");
            var count = ls2.length;
            var strLink = "";
            var optionItem;

            //Clear the previous options from the list
            for(var lstCount = strListBox.options.length-1; lstCount>-1; lstCount--)
                strListBox.options[lstCount] = null;
            if(count >= 2 )
                for(var x = count-1; x>=0; x--)
                        var ls3=ls2[x];//[x].split("|");
                        strLink+= ls3;
                        optionItem = new Option(ls3, ls3, false, false);
                        strListBox.options[strListBox.length] = optionItem;