Why am I not getting the value from onChange with Select?

dcp3450 picture dcp3450 · Aug 30, 2010 · Viewed 49k times · Source

Testing part of a form. So, right now I just want to alert what the user selects:

JS:

function getData(title)
{
     alert(title);
}

HTML generated by PHP:

<select name="currentList" onChange="getData(this);">
     <option value="hat">Hat</option>
     <option value="shirt">Shirt</option>
     <option value="pants">Pants</option>
</select>

when I change the value I get an alert with:

[object HTMLSelectElement]

Answer

meder omuraliev picture meder omuraliev · Aug 30, 2010

try alert(this.value)