Hi,
I have a form, and in this form, there are 2 drop down list a text box, one button (labelled "add" )and finally, a listbox.
The question is, when the user clicks on the add button, how do I add the value selected in the drop down list and the text box values and put it into the listbox? After adding to the listbox, the selected value needs to stay in the drop down menu and not get removed. Thanks in advance 4 2767
listbox1.option s[listbox1.length].text = textbox1.value;
listbox1.option s[listbox1.length].value = textbox1.value;
listbox1 would also contain a .selected value for the selected line as
well as .selectedIndex, however it should keep your selected index.
On Jun 10, 8:33*am, ranjini ns wrote:
Hi,
I have a form, and in this form, there are 2 drop down list a text box, one button (labelled "add" )and finally, a listbox.
The question is, when the user clicks on the add button, how do I add the value selected in the drop down list and the text box values and put it intothe listbox? After adding to the listbox, the selected value needs to stay in the drop down menu and not get removed. Thanks in advance
Hi,
That is a JS question, not a C# one,
In any case all y ou have to do is adding the new element to the list:
listbox1.option s[ listbox1.option s.length] = 'new element';
to delete an element simply set it to null:
listbox1.option s[ 1] = null;
That is a JS question, not a C# one,
I think I might have interpreted it as a Javascript question.
If you're doing it in C# just combine the drop down item and the
textbox however you were going to in the Add method and if the listbox
isn't keeping the selected index just make a note of the selected
index add the item then set the selected index back to what it should
be. Where you might run into problems is if your listbox gets too
long and the scrollbars start moving on you, in that case you can
search for a scrolling listbox on www.codeproject.com.
On Jun 10, 9:35*am, "cfps.Christian " <ge0193...@otc. eduwrote:
listbox1.option s[listbox1.length].text = textbox1.value;
listbox1.option s[listbox1.length].value = textbox1.value;
It's the option collection the oen with the length property, not the
select object This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Cardman |
last post by:
Greetings,
I am trying to solve a problem that has been inflicting my self
created Order Forms for a long time, where the problem is that as I
cannot reproduce this error myself, then it is difficult to know what
is going on.
One of these Order Forms you can see here...
http://www.cardman.co.uk/orderform.php3
|
by: Evan |
last post by:
I have searched high and low and am posting this question in the hope
that someone out there on the net can help me out. I am using a merge
of ASP and JavaScript.
My goal is to create 2 drop down lists. Both are populated from a
database using ASP, BUT the contents of the second list are dependant
on the selection of the first list. When the user selects the state in
the first list, then only the cities which reside in that state are...
|
by: binnyva |
last post by:
Hello Everyone,
I have just compleated a JavaScript tutorial and publishing the
draft(or the beta version, as I like to call it) for review. This is
not open to public yet.
The Tutorial is avaliable at...
http://www.geocities.com/binnyva/code/javascript/advanced_tutorial/
If any of you could spare the time, please have a look at my tutorial
|
by: Wysiwyg |
last post by:
After a server created cookie is processed on the client I want it removed,
cleared, or expired in the javascript block but have been unable to do this.
If I set a cookie value in the server code behind and don't use a domain
then I can not change or remove that cookie's value on the client. If I
subsequently create the cookie again in the codebehind then I actually end
up with TWO cookies with the same name in the response. The cookie...
|
by: deepak |
last post by:
hi eveyrone,
i have 2 listboxes , (both web controls),the first one is populating with
database at page loadtime, i also have 2 web control buttons to move values
between both list boxex ,actuaaly i want to add/remove the values from first
listbox to second and vice-versa using javascript , can any one help me
(plz show urs script).. and later i want to transfer the values of
selected texts in second listbox to database after adding(on...
| |
by: darrel |
last post by:
On some of my pages I add a javascript call dynamically to the BODY tag:
pageBody.Attributes.add("onload", "dothis();")
Since this adds an actual attribute, trying to call this multiple times
simply replaces the attribute I created rather than adding new values to the
existing attribute. Which makes sense.
But what if I want to append values to a single attribute. What's the proper
way to do that?
|
by: ayende |
last post by:
I got the following JS function:
<script language="javascript" type="text/javascript">
function addUser()
{
var users = document.getElementById('users');
var hidden = document.createElement('input');
hidden.value = 'foo';
users.appendChild(hidden);
var i =0;
|
by: bill |
last post by:
I need to be able to dynamically add items to a <asp:listbox> (or HTML
<select runat=server>) using clientside javascript, and retrieve the items
when the page is posted back.
I use this code to add the option to the listbox. It works for <select> or
<asp:listbox> controls.
var opt = document.CreateElement("OPTION");
opt.text = "test";
opt.value="test";
|
by: sorobor |
last post by:
dear sir ..
i am using cakephp freamwork ..By the way i m begener in php and javascript ..
My probs r bellow
I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ...
Pls inform me as early as possible ..
I am waiting for ur quick replay ...Here i attached the source code ....
<!DOCTYPE...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |