Getting VALUE of List Box using JavaScript...

Results 1 to 2 of 2

Thread: Getting VALUE of List Box using JavaScript...

  1. #1
    Join Date
    Dec 1969

    Default Getting VALUE of List Box using JavaScript...

    Hi,<BR>I have a list box named StaffName. I have an onChange event function named GetName for it. In the GetName function, I want to get the value of my ListBox the user selected. i.e. If the list box has Apple, Orange and Pear, let&#039;s say the user selected Pear. I want to place that value in some variable. I then want to use that variable to search the database to get all records that have Pear under Fruit field...<BR><BR>Can I reference that variable outside of my javascript function?<BR><BR>Thanks much!<BR><BR>Siya

  2. #2
    Join Date
    Dec 1969

    Default Value or Text???

    &#060;SELECT Name="Fruit"&#062;<BR>&#060;OPTION Value=1&#062; Apple<BR>&#060;OPTION Value=2&#062; Banana<BR>&#060;/SELECT&#062;<BR><BR>Do you want to get 1, 2, 3? Or Apple, Banana, Cantaloupe?<BR><BR>The code is almost identical:<BR><BR>var sel = document.FormName.SelectName;<BR>var val = sel.options[ sel.selectedIndex ].value;<BR>var txt = sel.options[ sel.selectedIndex ].text;<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