Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox Extracting the Displayed Text

Status
Not open for further replies.

RSQUARE

IS-IT--Management
May 3, 2004
5
US
Hi,
I have a dynamically generated listbox. The actual values for the list items are different from the displayed text. I need to get the displayed text and write it in a text box.

How to get the displayed items from the Listbox ?

Eg.


INTERNAL VALUE = 1
DISPLAYED VALUE = "ONE"

INTERNAL VALUE = 2
DISPLAYED VALUE = "TWO"

and so on...
I need to extract ONE, TWO etc from the List Box. How to do it ?

Thanks in advance.

RR.
 
If you mean from a form post then the answer is: you don't. But if it was you who populated the listbox then you should be able to get the displayed text the same way from the id.

If you just want to get the displayed text in a text box to be written in a text box on the fly then you have to do it in javascript.

4guysfromrolla.com has a lot of listbox examples:
 


<form name=Test>
Select:<select name=fSel onChange=&quot;DspText()&quot;>
<option value=1>AAAAA
<option value=2>BBBBB
<option value=3>CCCCC
</select>
<br>
Text: <input type=text name=fText readonly>
</form>


<script language=VBScript>

function DspText()
document.test.fText.value = document.test.fSel.options(document.test.fSel.selectedIndex).text
end function

</script>

br
Gerard
(-:

Better a known bug then a new release.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top