get the Value of a Select box





11
Date Submitted Thu. Oct. 5th, 2006 12:01 PM
Revision 1 of 1
Helper Idlemind
Tags ajax | JavaScript
Comments 4 comments
I use this in my AJAX as a quick way to get the Value of the selected item in a Select HTML object. If nothing is selected, it returns zero.
(May be basic to y'all, but maybe really usefull to someone else).

function fn_SelectedValue(selectId)
{
  theSelect = document.getElementById(selectId);
  selectedValue = theSelect.option[theSelect.selectedIndex].value;
  if(!selectedValue || selectedValue==null)
  {
    selectedValue = 0;
  }
  return selectedValue;
}
 

Brian Stork

Comments

Comments Where's the Ajax Part?
Thu. Oct. 5th, 2006 2:17 PM    Helper Thomas
  Comments It's about AJAX...
Mon. Oct. 9th, 2006 1:21 AM    Newbie mrspeaker
Comments you can do like this
Mon. Oct. 9th, 2006 3:00 AM    Syntax Master sundaramkumar
  Comments Needed a little more
Tue. Oct. 24th, 2006 11:30 AM    Helper Idlemind

Voting