Hej!
<style>
#startDate ,
#stopDate ,
#startTime ,
#stopTime ,
#startWeek ,
#stopWeek ,
#startMonth ,
#stopMonth { display: none }
</style>
<script>
// id:n på de element som berörs av visa/dölj-koden
var allIds = ["startDate","stopDate","startTime","stopTime","startWeek","stopWeek","startMonth","stopMonth"];
function f(sel){
var opts = sel.options,
affIds = [];
// i affIds läggs de id:n som skall visas beroende på menyvalet
switch (opts[sel.selectedIndex].text){
case "Tid" : affIds = ["startDate","stopDate","startTime","stopTime"]; break;
case "Dag" : affIds = ["startDate","stopDate"]; break;
case "Vecka": affIds = ["startWeek","stopWeek"]; break;
case "Månad": affIds = ["startMonth","stopMonth"]; break;
}
for (var i = 0; i < allIds.length; ++i){
var found = false;
for (var j = 0; j < affIds.length; ++j){
if (allIds[i] == affIds[j]){
found = true;
break;
}
}
var elm = document.getElementById(allIds[i]);
if (found){
elm.style.display = "block";
} else {
elm.style.display = "none";
}
}
}
</script>
<form>
<div>
<select onchange="f(this)">
<option>--------------</option>
<option>Tid</option>
<option>Dag</option>
<option>Vecka</option>
<option>Månad</option>
</select>
</div>
<div id="startDate">
<input name="startDate" value="startDate">
</div>
<div id="stopDate">
<input name="stopDate" value="stopDate">
</div>
<div id="startTime">
<input name="startTime" value="startTime">
</div>
<div id="stopTime">
<input name="stopTime" value="stopTime">
</div>
<div id="startWeek">
<select name="startWeek">
<option>startWeek</option>
</select>
</div>
<div id="stopWeek">
<select name="stopWeek">
<option>stopWeek</option>
</select>
</div>
<div id="startMonth">
<select name="startMonth">
<option>startMonth</option>
</select>
</div>
<div id="stopMonth">
<select name="stopMonth">
<option>stopMonth</option>
</select>
</div>
</form>
