PDA

View Full Version : Problem with selecting multiple item from Menu and showing in a text box


szms
Fri 18th Jul '03, 4:51pm
Hello everyone. I am trying to select couple of itemsfrom a menu bar and those will be displayed in a restricted text area (one in each row) where user can only give input by selecting item from menu list). But I am having problem with selecting items. When I select the next one the first one appeared in the text area and so on. Please have a look of the following code. Any suggestion.

<html>
<head>
<title>
</title>
</head>
<body>
<script>
function copythis(str)
{
document.myform.copied.value += str + '\n';
}
</script>

<form name='myform'>
<?php
$Domain_Name[] = "Cricket";
$Domain_Name[] = "Soccer";
$Domain_Name[] = "Table Tennis";
$Domain_Name[] = "Chess";
?>
<br>

<select name = "InputDomainMenu[]" Multiple onclick="copythis(this.options[this.selectedIndex].value);">

<?php
foreach ($Domain_Name as $Existing_Item)
print " <option value=\"$Existing_Item \">$Existing_Item</option>";
?>
</select>

<br><br>

<textarea name = 'copied' rows = "20" cols = "45"></textarea>

</form>

</body>

</html>