67 lines
2.0 KiB
HTML
67 lines
2.0 KiB
HTML
|
<script type="text/javascript">
|
||
|
var toplevel = new Array();
|
||
|
var level2 = new Object();
|
||
|
<%Plugins::GForum::Bikes::generate_brand()%>
|
||
|
|
||
|
function load(obj, source, selected) {
|
||
|
var oO = document.createElement('option');
|
||
|
//obj.appendChild(oO);
|
||
|
for (var i=0; i<source.length; i++) {
|
||
|
var oO = document.createElement('option');
|
||
|
oO.value = source[i].name;
|
||
|
oO.innerHTML = source[i].name;
|
||
|
if (selected == source[i].id) oO.selected = true;
|
||
|
obj.appendChild(oO);
|
||
|
}
|
||
|
obj.style.display = 'inline';
|
||
|
}
|
||
|
|
||
|
function remove(obj) {
|
||
|
while (obj.options.length > 0) {
|
||
|
obj.remove(0)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function loadSub(name, source, fatherID, subName, selected,loadtext) {
|
||
|
var obj = document.getElementById(name);
|
||
|
if (!obj) return;
|
||
|
|
||
|
remove(obj);
|
||
|
|
||
|
if (fatherID) {
|
||
|
var data = source[fatherID];
|
||
|
if (!data) { obj.style.display = 'none'; }
|
||
|
else {
|
||
|
load(obj, data, selected);
|
||
|
var obj2 = document.getElementById(loadtext);
|
||
|
if (obj2) obj2.style.display='inline';
|
||
|
}
|
||
|
}
|
||
|
else { obj.style.display = 'none'; }
|
||
|
|
||
|
if (subName) {
|
||
|
var subObj = document.getElementById(subName);
|
||
|
remove(subObj);
|
||
|
subObj.style.display = 'none';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<%if select_bike_id%>
|
||
|
<%loop user_bikes_loop%>
|
||
|
<%if bike_id != $select_bike_id%><%nextloop%><%endif%>
|
||
|
load(document.getElementById('bike_brand'), toplevel, '<%if bike_brand%><%bike_brand%><%else%>0<%endif%>');
|
||
|
<%if bike_brand%>
|
||
|
loadSub('bike_model', level2, '<%bike_brand%>', '', '<%if bike_model%><%bike_model%><%else%><%endif%>');
|
||
|
<%endif%>
|
||
|
<% set bike_found = 1 %>
|
||
|
<%endloop%>
|
||
|
<%endif%>
|
||
|
<%if not bike_found %>
|
||
|
load(document.getElementById('bike_brand'), toplevel, '<%if bike_brand%><%bike_brand%><%else%><%endif%>');
|
||
|
<%if bike_brand%>
|
||
|
loadSub('bike_model', level2, '<%bike_brand%>', '', '<%if bike_model%><%bike_model%><%else%><%endif%>');
|
||
|
<%endif%>
|
||
|
<%endif%>
|
||
|
</script>
|
||
|
|