"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Saturday, December 3, 2011

Add items in Drop Down List or List Box using Javascript

Hi *.*,
Add items in Drop Down List or List Box using JavaScript.



<script type="text/javascript">
    function AddItem(Text,Value)
    {
        // Create an Option object        
var opt = document.createElement("option");

        // Add an Option object to Drop Down/List Box
        document.getElementById("DropDownList").options.add(opt);
// Assign text and value to Option object
        opt.text = Text;
        opt.value = Value;

    }<script />


Actually script helped me a lot,when i play around ajax :). thanks to the creator
courtesy:http://chiragrdarji.wordpress.com/2007/06/06/add-items-in-drop-down-list-or-list-box-using-javascript/ 


If u had any trouble just ask, Happy to help u :) 
Stay Tune... 
Have a nice day... 'N happy Coding :)

3 comments:

Unknown said...

How can this be modified to add items from a sqlite database?

SImplyAsp said...
This comment has been removed by the author.
SImplyAsp said...

Use System.Data.SQLite.SQLiteParameter. Try this out. (I may have some syntax wrong because I'm not able to test this right now...but it should be similar)


SQLiteCommand cmd3 = new SQLiteCommand("select distinct(ACTION) from ACTION_LIST where CATEGORY=@category", conn2);
cmd3.Parameters.Add(new SQLiteParameter("@category",comboBox1.Text));