populating a select from an sql table created by a prior select

Posted on 2014-08-11
Last Modified: 2014-08-12
I have 2 selects in my form

The first one creates a table with the selections the client makes.

This table is cleared at the beginning.

The second select is based on 2 tables, a main table and the table crated in the first selection.

When I open the site all selections are clear, when I finish the first selection the second one is still clear, I need to populate without reloading the page since it resets all the tables. (mainly the first with the selected values)

Is there a way to have it populated when I hover or click on the 2nd select?
Question by:robrodp
    LVL 24

    Accepted Solution

    you need to use an ajax call to create the options list and then use this to populate the second select

    use jQuery for the ajax call, it will save you some time and effort

    use a call back function to populate the select with the new options
    at it's most basic it will be something like this
    			type: "GET",
    			url: "random-post.php?lang=" + $j.ifen('en','fr'),
    			dataType: "html",
    			success: function(msg){
    						//do something;		                

    Open in new window

    some caveats

    some versions of IE do not like having the option list updated so you will need to replace the entire select
    LVL 21

    Expert Comment

    by:Kim Walker
    The first one creates a table with the selections the client makes.
    Can you be more specific? It sounds as if this part is working except it's not populating the second select. Is that correct? If so, are you using ajax to create this table or are you submitting and reloading the page when the first selection is made?

    Author Closing Comment

    Thx.. the IE comment makes it a no no.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now