View Full Version : Chained Menu go without go button

08-28-2008, 08:20 PM
1) Script Title: Chained Menu go with out go button

2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ects/index.htm

3) Describe problem: Great Script and I have everything working as planned, but now I would like to have the go button not show up until the last option is choose or once the last option is choose then have it goto a new page.


08-28-2008, 11:30 PM
You can forgo the "Go" button and have the menu respond as soon as the last select menu is selected by the user with the following. Using the default HTML code of the demo page:

<body onload="initListGroup('chainedmenu', document.listmenu0.firstlevel, document.listmenu0.secondlevel, document.listmenu0.thirdlevel, 'savestate')">

<form name="listmenu0">
<table align="center"><tr>
<td><select name="firstlevel" style="width:180px;"></select></td>
<td><select name="secondlevel" style="width:160px;"></select></td>
<td><select name="thirdlevel" style="width:160px;"></select></td>
<td><input type="button" value="Go" onclick="goListGroup(document.listmenu0.firstlevel, document.listmenu0.secondlevel, document.listmenu0.thirdlevel)">
<input type="button" value="Reset" onclick="resetListGroup('chainedmenu')">

You'd add to it (following the above code) the below:

<script type="text/javascript">

function ddaddEvent(target, functionref, tasktype){
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false);
else if (target.attachEvent)
target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});

ddaddEvent(document.listmenu0.thirdlevel, function(){
goListGroup(document.listmenu0.firstlevel, document.listmenu0.secondlevel, document.listmenu0.thirdlevel)
}, "change")


Make sure the lines in red match the information within the original HTML code above it. With the extra code, the 3rd select menu reacts as soon as a choice has been selected within it, without having to click on the "go" button.