Technologies: PHP, JavaScript (.js), MySQL.
Note: On my PHP server: <input type=* name="A_NAME" ...>
is transformed directly into $A_NAME, which may happen not to work
on some other server (off by default) => use $_POST['A_NAME'] or
$_GET['A_NAME'] instead.
Problems: Some browser have JavaScript disabled thus a form validation doesn't work for them. It would be better to use PHP instead of JavaScript for this purpose.
| File name | Description |
|---|---|
| Questionnaire 1 | All fields except for one text field must be set. |
| a_rpg.html | A questionnaire. Generic form validation (.js; check for required fields) + validation of correctness of a 4 digit number. |
| a_rpg_zprac.php.txt | Processing the questionnaire. PHP: 1) (Dis)Connect MySQL database (DB). 2) Form results (checkboxes!, radios, text fields) stored to DB. |
| Questionnaire 2 | A respondent shall enter 1-3 names in a normalized form. The names entered are compared to a list of names, if not there the list opens in a new window so that the user can pick a name. Communication between 2 windows (.js). |
| a_topten.html | The questionnaire. Form validation (compare a string to a list of names, open the list). |
| a_topten_ucitele.html | The list of users as presented to a user (read from a .js file). Store a selected name to the appropriate text field in the questionnaire (window<->window communication). |
| a_topten_ucitele.js.txt | .js file with an array of valid names. It must be in the same encoding (iso-8859-2) as the .html file it's written into => if created under MS Windows an encoding convertor ([CZ]) must be used. |
| a_topten_zprac.php.txt | Quite the same but simpler than a_rpg_zprac.php.txt except for letting the user know if he/she has entered an UČO (used as a primary key) that has already been used. |
Technologies: PHP, JavaScript (.js)
| File name | Description |
|---|---|
| anketa.php.txt | A questionnaire with 3 (actually 4) sections: main ("Hlavni
stranka"), 1st (Sekce 1) and 2nd (Sekce 2) (and processing of the
form). Requirement: Only 1 section is visible in a time and you can
switch among them (Submit buttons [Sekce I], [NÁVRAT NA HLAVNÍ STRÁNKU]).
Once you filled a section its content is never lost and you can return
to it. All is stored into a database as 1 record. Solution: 1) All
sections are on 1 page (form) and PHP displays only 1 of them according
to the value of <input type="hidden" name="co_zobrazit"
value="<?php echo $_POST['co_zobrazit']; ?>" >
which is set by every button by JavaScript. TO DO: To remeber content
("value"/"selected"/"checked") of all form
elements we must use PHP to set it always according to its value in
$_POST[] (not yet tested; note that $_POST is always set):<input type="text" name="X" value="<?php if( isset($_POST['X']) ) echo "$_POST['X']"; ?>" > <input type="radio" name="X" value="N" <?php if(isset($_POST['X']) && $_POST['X']==N) echo "checked"; ?> > <input type="checkbox" name="X" <?php if( isset($_POST['X']) ) echo "checked"; ?> > |
See The Dynamic tree menu page.
Jakub Holý 2003AD