hey is there any way i can dynamicallay pupulate 3 drop downs ie when based on d selection of a value from 1st drop down populate 2nd drop down and based on value selected in 2nd srop down populate 3rd drop down,but i wan this to happen in my edit page so i dont want the dynamic drop down population to reload the page.initially when i click on edit there have to the 3 drop downs showing the value that is stored in the database and if i wnna change the values th page shouldnt get reloaded cos there will be other text boxes on the page as well,holding the value stored in the databse.hpe this makes sense!

Recommended Answers

All 7 Replies

hey is there any way i can dynamicallay pupulate 3 drop downs ie when based on d selection of a value from 1st drop down populate 2nd drop down and based on value selected in 2nd srop down populate 3rd drop down,but i wan this to happen in my edit page so i dont want the dynamic drop down population to reload the page.initially when i click on edit there have to the 3 drop downs showing the value that is stored in the database and if i wnna change the values th page shouldnt get reloaded cos there will be other text boxes on the page as well,holding the value stored in the databse.hpe this makes sense!

Simple solution is you need to make ajax calls to achieve this.

In your edit form add 3 divs,
1st one for first select box(Which will be shown when you edit the page)

2nd one to show 2nd selectbox(default behaviour of this div will be display:none) on selecting the option from 1st selectbox, onchange event this will be shown by loading the data from database and make this to display:block

3rd one to show 3rd selectbox(default behaviour of this div will be display:none) on selecting the option from 2st selectbox, onchange event this will be shown by loading the data from database and make this to display:block

i dnt want the drop downs to be blank initially.they should show the corresponsing selected value from the databse.and i dont kno ajax at all.isnt there any way i could do it in php itself?

i dnt want the drop downs to be blank initially.they should show the corresponsing selected value from the databse.and i dont kno ajax at all.isnt there any way i could do it in php itself?

Then there is another solution to do for this,

Read the complete data from the database and take them in javascript arrays. so onChange of first dropdown select the relavant data from the loaded javascript array and fill the second dropdown with that data, and similarly for the 3rd select box.

For this process Ajax is also not necessary.

can u give me an example of how 2 do it.actually im new to php and not very good at it o javascript either

can u give me an example of how 2 do it.actually im new to php and not very good at it o javascript either

Oh, you are new to PHP and javascript, Sounds good

FYI I am sorry, I can't sit and write code for you, If you try the method which I told you, and any problems you are facing in that code i can help you.

If you are very much new to the concepts as well please read the javascript tutorials and PHP tutorials.

hey,i have a slight idea how to do it.i should GET the value from the 1st drop down and accordingly populate the 2nd drop down.but if i wanna select a different value from the 1st drop down,i'l have to use "onchange=reload(form)".m i rite?
but i cannot reload the form since its a edit form.i need to retain the values.is that possible?

hey,i have a slight idea how to do it.i should GET the value from the 1st drop down and accordingly populate the 2nd drop down.but if i wanna select a different value from the 1st drop down,i'l have to use "onchange=reload(form)".m i rite?
but i cannot reload the form since its a edit form.i need to retain the values.is that possible?

Yes you can reload by passing all the values again, If you don't want to use it like that, download any one of javascript framework like mootools or jquery or prototype or which ever is you are familiar with and make an Ajax call using your js framework.

It is much easier to make Ajax calls with js frameworks, and you can even find example of making an Ajax call.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.