Commit db3d9f49 authored by Dong Huu Cao's avatar Dong Huu Cao
Browse files

testing the dropdown menu

parent 002bab25
//put the content in a .js file
function create_dropdown(element_id,data_file_name = '')
{
//var options_list = fs.readFileSync("test_input.dat").toString().split("\r\n");
var options_list = ['Program 1', 'Program 2', 'Program 3'];
var dropdown_menu = document.createElement('select');
for (i = 0; i < options_list.length; i++)
{
var option = document.createElement('option');
option.value = options_list[i];
option.innerText = options_list[i];
dropdown_menu.appendChild(option);
}
dropdown_menu.id = element_id + " menu";
dropdown_menu.style.display = "none";
dropdown_menu.style['margin-left'] = "30%";
document.getElementById(element_id).appendChild(dropdown_menu);
}
function show_hide(element_id)
{
var element = document.getElementById(element_id);
if (element.style.display === "none") {
element.style.display = 'block';
}
else {
element.style.display = "none";
}
}
create_dropdown('demo');
//document.getElementById('demo').onclick = "show_hide('demo menu')";
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TEST BOX</title>
</head>
<body>
<div id="demo", onclick="show_hide(id + ' menu')",
style="
width: 200px;
height: 200px;
margin-top: 10%;
background-color: #db584f;
margin-left: 40%;
display: inline-block;
text-align: center;
font-size: 20px">
Click Me!
</div>
<script src="test.js"></script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment