Possible Duplicate:
Get Default Value From select field Javascript
I use a javascript function and the ‘window.beforeunload’ property to check to see if the user has made any changes to my web form before leaving the page. In this function I compare the defaultValue of the text fields with the value. However I have added two ListBoxes to the form and the defaultValue method isn’t working for them. What can I use in its place for the Selects?
Text field example:
if(document.forms['form2']['itemID'].value != document.forms['form2']['itemID'].defaultValue)
{return 'There are unsaved changes in the form!'}
It’s
defaultSelectedfor select’s option elements.REF: https://developer.mozilla.org/en-US/docs/DOM/HTMLOptionElement