TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kumar AU
1.1k
309
61.9k
Add and Remove text box value to ListBox Items in JavaScript
Aug 6 2014 8:52 AM
Can any one please tell me in ASP.NET How to ADD or REMOVE text box value to List Box item using Add and Remove buttons this should be done using Java script only without server post back.
This is my code, but its not working.
ASPX :-
<input type="button" value="Add Item" onclick="javascript:addValue()" />
<input type="button" value="Delete Item" onclick="javascript:deleteValue()" />
<asp:TextBox ID="txtValue" runat="server"></asp:TextBox>
<asp:ListBox ID="LstChanelType" runat="server"></asp:ListBox>
Javascript :-
<script type="text/javascript">
var i = 0;
function addValue() {
var v = document.form1.txtChanelType.value;
// get the TextBox Value and assign it into the variable
AddOpt = new Option(v, v);
document.form1.LstChanelType.options[i++] = AddOpt;
return true;
}
function deleteValue() {
var s = 1;
var Index;
if (document.form1.LstChanelType.selectedIndex == -1) {
alert("Please select any item from the ListBox");
return true;
}
while (s > 0) {
Index = document.form1.LstChanelType.selectedIndex;
if (Index >= 0) {
document.form1.LstChanelType.options[Index] = null;
--i;
}
else
s = 0;
}
return true;
}
</script>
Always here i am getting an error message :-
Compiler Error Message:
CS1026: ) expected
Line 192: <asp:Button ID="add" Text="Add" CssClass="form_submit" runat="server" onclick="javascript:addValue()" />
Please please help me...
Reply
Answers (
1
)
abstract data type in .net
Files are not deleting from Server by ASP.net website