How to Keep the selected value of the select box after Form POST or GET

前端 未结 8 1995
無奈伤痛
無奈伤痛 2021-01-03 15:33

Im trying to implement the search feature in my website.

when the search keyword is entered in the textbox, and the category combo is selected, the form will be Pos

8条回答
  •  一向
    一向 (楼主)
    2021-01-03 15:43

    Assuming that by "combo" you mean "A regular select element rendering as a drop down menu or list box" and not "A combobox that is a combination of a drop down menu and free text input":

    When outputting the elements, check the value against the submitted data in $_POST / $_GET and output selected (in HTML) or selected="selected" (in XHTML) as an attribute of the option element.

提交回复
热议问题