This Demo Contains Two Types of Select Box Emulation Functions
- The mm_changeParentText() function emulates a select box within the Milonic Menu.
- The mm_setSelected() function allows the Milonic Menu to be placed in a form and emulate a select box.
I. To use the changeParentText() function:
- Place the following code at the top of your menu_data.js file:
function changeParentText()
{
_i=getParentItemByItem(_itemRef)
_mi[_i][1]=_mi[_itemRef][1]
_item=gmobj("el"+_i)
_item.innerHTML=BDMenu(_mi[_i][0])
itemOn(_i)
}
- Define a menuStyle in your menu_data file. This style will be used by the 'dropdown'. Include the following line:
clickfunction="changeParentText();";
- Define a mainStyle for the main menu and include the following:
clickfunction="";
- Define your main menu [this will be the 'box'] and include the following in the aI string.
openonclick=1;closeonclick=1;keepalive=1;");
In this sample the aI string is:
aI("text=Please Select Your TLD;showmenu=TLD;openonclick=1;closeonclick=1;keepalive=1;"); - Define your sub menu with the wanted items
- Place the calls for the menu as you would any menu.
II. To use the setSelectBox() function:
In this example the milonic select box is used inside a form. The function changes the text of the select box item and also places the result of the selection into a form field. In the sample, this field is coded as a normal, visible text input field so you can see the field's value change with the selection. In practice, you would set the input type to "hidden". That way, the field isn't seen, but its value is set according to the selection in the pseudo select box. The advantage of doing it this way is that the result of the selection (and any other pseudo select boxes in the form) remains inside of the form and can be easily processed along with other fields in the form.
- Set up your menu data file as usual. In this sample the file contains the style definitions, the selectBox menu, and the Options menu.
-
Place the following code at the top of your menu_data.js file
function setSelected()
{
selectedItem = _itemRef;
selectedText = _mi[selectedItem][1];
parentItem = getParentItemByItem(selectedItem);
_mi[parentItem][1] = selectedText;
BDMenu(_mi[parentItem][0]);
document.forms['myForm'].selectHolder.value = selectedText;
menuDisplay(_mi[selectedItem][0], 0);
}
- Create your form in your html page.
- From the menu data file remove the selectBox menu you created and place it in the form within
script tags including the drawMenus(); at the end of it. [ the same method as that for placing a menu in a table ]
The following is the form used in this sample. NOTE the position="relative":
<form name="myForm" onsubmit="showSelectValue()">
Select:<br>
<script language="javascript">
with(milonic=new menuname("selectBox")){
style=selectStyleMain;
top=10;
left=10;
alwaysvisible=1;
orientation="horizontal";
position="relative";
itemwidth=120;
aI("text=Select an Option;showmenu=Options;openonclick=1;closeonclick=1;offborder=inset 2px;");
}
drawMenus();
</script>
<input type="submit" value="Submit">
Your Selection:<br>
<input type="text" name="selectHolder" size="15">
</form>