...

View Full Version : textbox to multi-select



FlashO
04-23-2008, 12:37 PM
hi กก
I have a textbox and I want spend their content in text to the list selected of a select multiple.
I found code to do the opposite mode but I don't serve for me.
Someone can help me?

Thanx :thumbsup:

chump2877
04-23-2008, 02:42 PM
something like this perhaps:


<?xml version="1.1" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>TITLE</title>
</head>
<body>

<p>
<select id="menu" multiple="multiple" size="4">
<option value="Item #1">Item #1</option>
<option value="Item #2">Item #2</option>
<option value="Item #3">Item #3</option>
<option value="Item #4">Item #4</option>
</select>
</p>
<p><input type="text" id="newtext" /> <input type="button" value="Send to Menu" onclick="sendToMenu('newtext','menu');" /></p>

<script type="text/javascript">
function sendToMenu(textBoxID,menuID)
{
var txtBox = document.getElementById(textBoxID);
var menu = document.getElementById(menuID);
var regex = /^[\s]+$/;

if (!regex.test(txtBox.value) && txtBox.value != "")
{
var newOption = document.createElement("option");
newOption.value = newOption.innerHTML = txtBox.value;
menu.appendChild(newOption);
menu.size += 1;
}

txtBox.value = "";
txtBox.focus();
}
</script>

</body>
</html>

FlashO
04-23-2008, 04:13 PM
:thumbsup::thumbsup::thumbsup::thumbsup: Is perfect
Thankss:D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum