Monday, March 8, 2010

Use Javascipt to change the <select> Pre-select Item

I use this to change:

document.getElementById('idname').selectedIndex = 0;

Tested to work fine with latest IE, Firefox, Safari and Chrome. Your <select> also needs to address the id name such as:

<select id=idname>

You can change the selectedIndex to something else. 0 means the first selection, 1 means the second, etc.

No comments:

Post a Comment