<div class="span10 center"> <div class="span12"> <input name="txtValue" type="text" /> @Html.TextBox("txtValue",null, new { @class = " input-block-level", placeholder = "Add Recipient's Number" }) </div> <div class="btn-group"> <button class="btn btn-success" type="submit" onclick="addItem();">Add Recipient</button> <button class="btn btn-danger " type="submit" onclick="deleteValue();">Remove Recipient</button> </div> <br /> <br /> <div> <label>Recipients </label> @Html.ListBox("myListBox", new SelectList(new[] { "" }), new { name = "lstValue", style = "width: 250px; height: 160px;" }) </div> </div>
function addItem() { if (txtValue.value() != '') { myListBox.options.add(txtValue.value()); txtValue.value(''); } else { alert('Please Type A Recipient Contact .'); } return false; } function removeItem() { var selectedIndex = ListBox1.selectedIndex(); clearSelection(); if (selectedIndex != -1) { ListBox1.options.remove(selectedIndex); } else { alert('select a Recipient to remove.'); } return false; } function clearSelection() { ListBox1.selectedIndex(-1); ListBox1.value(''); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)