Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 7th, 2007, 01:33 AM
Authorized User
 
Join Date: Aug 2006
Location: Mumbai, Maharastra, India.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default adding items to list box using javascript

hi friends


i have one text box in which i will enter some value

that value i want to add to list box

how can i do this


thanks


  #2 (permalink)  
Old February 7th, 2007, 02:15 AM
Friend of Wrox
Points: 1,935, Level: 17
Points: 1,935, Level: 17 Points: 1,935, Level: 17 Points: 1,935, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: United Kingdom
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi

You can use the JS function below to fullfil your requirement:

function AddItems()
        {
            var myForm = document.Form1; //Form Name
            var mySel = myForm.sel; // Listbox Name
            var myOption;

            myOption = document.createElement("Option");
            myOption.text = document.getElementById("txt").value; //Textbox's value
            myOption.value = document.getElementById("txt").value; //Textbox's value
            mySel.add(myOption);
        }

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
  #3 (permalink)  
Old February 7th, 2007, 05:29 AM
Authorized User
 
Join Date: Aug 2006
Location: Mumbai, Maharastra, India.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi mike

thanks for reply

i tried it its working fine


but items of list box which i have added using javascript
 i am not able to refer in codebehind file


thanks

  #4 (permalink)  
Old February 16th, 2007, 06:32 AM
Registered User
 
Join Date: Feb 2007
Location: Chandigarh, UT, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to balpreet.patil Send a message via Yahoo to balpreet.patil
Default

hi..buddy...

As u have added list items in drop down, it fine but when we add list items using javascript we can't access those items in code behind.
so, solution to this problem is store dropdown's selected value or text whichever u need in some hidden server control at onChange event(java script) and read that value from that hidden control in your code behind.

if u still face any problem e-mail me at balpreet.patil@gmail.com

thanks..

Balpreet...

Balpreet Patil
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Placing database items into a list box hookenbook Visual Basic 2005 Basics 2 January 14th, 2009 08:56 PM
put mailto: links on list items in a combo box? webwolf Flash (all versions) 0 September 12th, 2008 08:01 AM
Moving Selected Items from a list box to excel AlanAtMars SQL Server 2000 2 August 19th, 2005 02:02 PM
Choosing Multiple Items in a List Box HenryE Access 1 July 25th, 2005 07:14 AM
list box 2 show items according 2 current variable warrenb24 ADO.NET 0 December 20th, 2004 12:01 PM



All times are GMT -4. The time now is 01:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.