0

and show form based on that variable in single page, without pressing SUBMIT or buttons?

i have loop for fill 'select' in FORM

echo '<select name="inne_zad" class="cfpa" width="400" style="width: 400px"  >';
    echo '<option value="">Nr Zadania | Typ Zadania | Nazwa Wioski</option>';
        while($option = mysql_fetch_assoc($zadanie1)) {
            echo '<option value="'.$option['id_zadania'].'">'.'&nbsp;'.$option['id_zadania'].'&nbsp;-&nbsp;'.$option['rodzaj_zadania'].'&nbsp;-&nbsp;'.$option['zad_cel_nazwa'].'&nbsp;'.'</option>';


        }
echo '</select>';

and css rule

<style>
 .cfp {  display: none;   }
.cfpa:checked + .cfp {
    display: block;
  }
</style>

and div outside form (inside FORM css display none - not working..

echo '      <div class="cfp">';
echo '        some other content';
            if ($_POST['id_zadania'] == 7 ){ echo 'wybrales 7'; }
echo '    </div>';

I want to get selected variable, and display other part of the FORM

is it possible with PHP and CSS only?

zoore
  • 293
  • 5
  • 13
  • **Please, [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php).** They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). **Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement)** instead, and **use [PDO](http://us1.php.net/pdo).** – Jay Blanchard Jan 21 '15 at 14:27
  • thanks, but that is not the matter of the case.. – zoore Jan 21 '15 at 14:33

1 Answers1

0

If you don't want to press a button you can use the event onChange.

echo '<form>
<select name="inne_zad" class="cfpa" width="400" style="width: 400px" onChange="this.form.submit();" >';
  • it is helpfull but I would like to avoid passing variables from PHP to JS, and back. There are other parts of the form that I have to control, and JS is an easy break into code.. – zoore Jan 21 '15 at 15:15