Hi Juriy and welcome to the SitePoint forums, the first thing i would like to point out is not to use $_GET queries with Ajax unless you escape the incoming value as they are more prone to attack.

From what i can gather from the code you have above is when you select an option from your cg select box that gets sent to your searchbox.php script which then generates another sub select box with more selections.

You question regarding this would be what code would you need to write for the selected="selected" attribute, is that correct?

If so then my simple answer would be at this point nothing, without having a value to match against the IF statement you just need the <option> element for now. When it comes time to selecting that value you can do this very easily using jQuery as it appears your using that framework.

On a side note i can see improvements which will increase the performance of your onchange event, please see the updated code below...

Hi Juriy and welcome to the SitePoint forums, the first thing i would like to point out is not to use $_GET queries with Ajax unless you escape the incoming value as they are more prone to attack.

From what i can gather from the code you have above is when you select an option from your cg select box that gets sent to your searchbox.php script which then generates another sub select box with more selections.

You question regarding this would be what code would you need to write for the selected="selected" attribute, is that correct?

If so then my simple answer would be at this point nothing, without having a value to match against the IF statement you just need the <option> element for now. When it comes time to selecting that value you can do this very easily using jQuery as it appears your using that framework.

On a side note i can see improvements which will increase the performance of your onchange event, please see the updated code below...

thank you for your reply. then Im moving to show.php I would like to see everything that I selected in index.php. How to make option from searchbox.php be "selected" because all selections should already be done in index.php i need to show appropriate cg and subj in show.php