javascript - Easily manage user input forms in a PHP Web Application -
dear stackoverflowers,
i'm writing simple web application in plain html+php. i'm not using framework, content manager or anything.
the entry page has few checkboxes, 2 textboxes , series of dropdown menus. once selected, user clicks "search" button , runs php code , returns output.
the problem dropdown menus. code following :
<form action=$script method=\"get\" name=\"org\"> <select name=\"org\" onchange=\"javascript:document.org.submit();\"> <option value=\"0\">(default all)</option> <option value=\"1\">cars</option> <option value=\"2\">parts</option> </select> </form>
then every time user selects option, webpage reloaded , variable set. have 2 problems :
1.- option selected in dropdown menu shown first, user knows has clicked. way put php switch @ beginning of form , echo new dropdown menu depending on variable set in previous submitform.
2.- have create nightmarish spaguetti code in index.php handles if user has clicked on search button or not, etc.
is there anyway handle in more professional , easy way ? wether javascripts, frameworks or php modules. or tutorial.
thanks in advance.
1.) add selected selected option
<option value=\"1\" selected>cars</option>
2.) check if parameters set or not (if set, form has been submitted)
Comments
Post a Comment