List Box Selected Item Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mvmashraf
    New Member
    • Oct 2007
    • 36

    List Box Selected Item Problem

    Hai To all.
    I need to get the Slected Item from the listBox, I did used the following script,
    [code=javascript]
    function warn_DeleteToUs er()
    {
    var x =document.getEl ementById("ctl0 0_WorkArea_lstF ieldGroups");
    for (i = 0; i < document.getEle mentById("ctl00 _WorkArea_lstFi eldGroups").opt ions.length; i++)
    {
    if (document.getEl mentById("ctl00 _WorkArea_lstFi eldGroups").opt ions(i).selecte dItem)
    {
    var xy=document.get ElementById ("ctl00_WorkAre a_lstFieldGroup s").options(i). text;
    }
    }

    }

    [/code]
    But It shows error as Object Doennot support this prooperthy or methodes in the line
    [code=javascript]
    if (document.getEl mentById("ctl00 _WorkArea_lstFi eldGroups").opt ions(i).selecte dItem)
    [/code]
    What may the reson, I am using IE 7.

    Any help should be appreciatable

    By Ashraf
    Last edited by Frinavale; Nov 13 '07, 02:29 PM. Reason: Added [code] tags
  • mzmishra
    Recognized Expert Contributor
    • Aug 2007
    • 390

    #2
    if (document.getEl mentById("ctl00 _WorkArea_lstFi eldGroups").opt ions[i].selected == true)
    var xy=document.get ElementById ("ctl00_WorkAre a_lstFieldGroup s").options[i].value;

    Comment

    • mvmashraf
      New Member
      • Oct 2007
      • 36

      #3
      Again It shows eror as Object Doesnot support this property or methodes in the line

      if (document.getEl mentById("ctl00 _WorkArea_lstFi eldGroups").opt ions[i].selectedItem== true)


      Any Help

      Comment

      • mzmishra
        Recognized Expert Contributor
        • Aug 2007
        • 390

        #4
        Try selected instead of selected item
        see my above code

        Comment

        • mvmashraf
          New Member
          • Oct 2007
          • 36

          #5
          Ya. thanks alot Mirza. THe prbklem becomes solved

          Once again thanks

          Comment

          Working...