Saturday, March 22, 2008

Making a HTML select readonly

For some time ago I needed to make a single select <select> element readonly. This meant that the user should be able to see all values in the list and not be able to select a new value. There is no readonly attribute available for the <select> element and disabling the field was not an option since we needed the value on the serverside. Some simple javascript did the job:


<select name="theselect" onchange="this.selectedIndex = 1;">
<option value="Red">Red</option>
<option value="Green" selected="selected">Green</option>
<option value="Blue">Blue</option>
</select>

Initial value is green and it should continue to be. This solution rely on the possibility to apply the correct onchange eventlistener during the page rendition - in this case through a taglib. I have created a simple test page for myself here.

Friday, March 21, 2008

HTTP directory listing alternative

The other day I created a Maven repository on a webserver where directory listing is not allowed. For the repository folder and subfolders its very practically that you can browse the contents and since the server configuration is out of my hands I looked for an alternative. I found a free PHP alternative which was very easy to integrate. Simply unzip and place the script and icons in the folder which should be browseable then your done. You can extend the script to show correct icons for file types not already know by the script.