Trying to read back values from a listbox

Results 1 to 2 of 2

Thread: Trying to read back values from a listbox

  1. #1
    Join Date
    Dec 1969

    Default Trying to read back values from a listbox

    I have a listbox on a page which the user adds items to by entering the value and clicking a button. the value is then placed in the listbox. the trouble is when i try and read back the values by looping through the listbox the are blank. If I hardcode values in to the listbox &#060;OPTION value="hello"&#062;hello&#060;/OPTION&#062; and try and read them it is ok. Can you not read back values from a dynamically created listbox.<BR>function save(t){<BR> <BR> for(var i=0;i&#060;document.frm_Item.lstKeywords3.length;i ++){<BR> alert(document.frm_Item.lstKeywords3.options[i].value)<BR> } <BR>}<BR>????

  2. #2
    Join Date
    Dec 1969

    Default Maybe you should use .text property?

    ...instead of values?<BR><BR>Since you don&#039;t show your code that adds the "values", I can&#039;t tell. But the visible part of any &#060;OPTION&#062; is *not* its .value is the .text property. Maybe you aren&#039;t actually giving any .value properties to those new &#060;OPTION&#062;s???<BR><BR>&nbsp; &nbsp; allvals = "text for lstKeywords3:
    ";<BR>&nbsp; &nbsp; sel = document.frm_Item.lstKeywords3;<BR>&nbsp; &nbsp; for(var i=0; i &#060; sel.length; i++ ) allvals += (sel.options[i].text + "
    ");<BR>&nbsp; &nbsp; alert( allvals );<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts