[Solved] javascript dispalying a previous form


I hope I get the point what you wanted to ask.
You can post the chosen category and use it on the page running the same function when the document is ready.
Look:

<form method="POST">
    <select id="catego" name="catego">
      <option value="1" <?php if (isset($_POST['catego']) and $_POST['catego'] == '1') echo 'selected'?>>a</option>
      <option value="2" <?php if (isset($_POST['catego']) and $_POST['catego'] == '2') echo 'selected'?>>b</option>
      <option value="3" <?php if (isset($_POST['catego']) and $_POST['catego'] == '3') echo 'selected'?>>c</option>
    </select><br/>
    <input id="a" name="a" type="text" value="<?php if (isset($_POST['a'])) echo $_POST['a']?>"><br/>
    <input id="b" name="b" type="text" value="<?php if (isset($_POST['b'])) echo $_POST['b']?>"><br/>
    <input id="c" name="c" type="text" value="<?php if (isset($_POST['c'])) echo $_POST['c']?>"><br/>
    <input type="submit">
</form>

<script src="https://stackoverflow.com/questions/31595766/lib/jquery/dist/jquery.js"></script>

<!-- build:js js/vendor.min.js-->
<!-- bower:js-->
<!-- endbower-->
<!-- endbuild-->
<!-- build:js js/app.min.js-->
<!-- endbuild-->

<script>

function catego() {
    if ($('#catego').val() == 1) {
        $('#a').removeClass('hide');
        $('#b').addClass('hide');
        $('#c').addClass('hide');
    }
    if ($('#catego').val() == 2) {
        $('#b').removeClass('hide');
        $('#a').addClass('hide');
        $('#c').addClass('hide');
    }
    if ($('#catego').val() == 3) {
        $('#c').removeClass('hide');
        $('#a').addClass('hide');
        $('#b').addClass('hide');
    }
}

$('#catego').on('change', catego);

$( document ).ready(function() {
    catego();
});

</script>

Good luck!

1

solved javascript dispalying a previous form