Forum Moderators: open

Message Too Old, No Replies

Text Input/Drop Down Menu

Such thing?

         

adni18

5:40 pm on Sep 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You may have seen in word or powerpoint, how there are drop-down menus that can have its value edited. Is there a way to do this is javascript?

korkus2000

6:31 pm on Sep 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Those are called combo boxes. I do not know of a way to do it in javascript.

Rambo Tribble

10:33 pm on Sep 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Gosh, it should be possible to modify virtually anything that is part of a page (possible, not necessarily advisable). I'm not really familiar with Microsoft products, but here's a script I did for another question on the board, how to add to a select box. Maybe it will give you some ideas.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function xcats(select) {
if (select.value!= "new") return;
var catName = prompt('Please enter category name:','');
if (!catName) return;
var newOption = document.createElement("option");
newOption.value = catName;
newOption.appendChild(document.createTextNode(catName));
select.insertBefore(newOption, select.lastChild);
select.selectedIndex = select.options.length-2;
}
</script>
</head>
<body>
<form name="test">
<select name="cats" onchange="xcats(this)">
<option value="general">General</option>
<option value="community">Community</option>
<option value="new">New category</option>
</select>
</form>
</body>
</html>