Listbox update from database
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Listbox update from database

  1. #1
    Join Date
    Apr 2007
    Posts
    5

    Listbox update from database

    Hi,
    I am having problem to getting exact solution. actually i have listbox and data coming inside listbox from sql server. now i want if new row addedd in database table so listbox add new item for new database row at real time. i have try this using javascript but fail so now looking solution in ajax.

    i am stuck to found solution for last 1 week, is any one can help me in this please?

    Thanks a Lot

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,871

    Re: Listbox update from database

    Quote Originally Posted by nedoch View Post
    i have try this using javascript but fail so now looking solution in ajax.
    First off, AJAX is an implementation, not a language known as Asynchronous JavaScript and XML. So, this would be a JavaScript solution.

    There are tons of examples of this here at CodeGuru and across the internet. Remember to search Google. Also, take a look at this thread.

    As for the real-time implementation, you will just have to keep sending AJAX requests at an interval after the previous return is completed.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Apr 2007
    Posts
    5

    Re: Listbox update from database

    Thanks for reply. i try to do this with ajax, but ajax get refresh all items in listbox, but i want that if new row addedd in database then one item addedd in list box and old items not changed..

    actually i am developing web base Tick Data for *****. where every seconds 2-3 new ticks come in database so i want show tick data in listbox. i check diffrent example of ajax but not getting what i want, can you guide me if i am going in wrong way or i need to make API for them if ajax not work here?

    Thanks

  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,871

    Re: Listbox update from database

    If you only want to add the items that change in the database, then you are going to have to make an array of all items. Then, just check the array. If the item exists in the array, skip it. If it doesn't, then add it to the drop down.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Apr 2007
    Posts
    5

    Re: Listbox update from database

    Well, can i pass php array to javascript array? i try to do this in ajax but i dont have experience in ajax , can you give any simple example where ajax file get array from php and pass to javascript array?

    Thanks

  6. #6
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,871

    Re: Listbox update from database

    No, not a PHP array, a JavaScript array. When you first call the ajax, add each item to a JavaScript array. Then, every time you update, check to see if the item is already in the JavaScript array. If it is, skip over it.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Apr 2007
    Posts
    5

    Re: Listbox update from database

    HI,
    I have solve the issue, but now trap in next problem, actually listbox add item from database fine but problem is its add newest item at the end but i want add newest item at top of the listbox ,so that listbox show newsest item first, so is there any way to manage this in javascript or this is not possibal?

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center