Skip to content Skip to sidebar Skip to footer

Remember Selectbox Value After Form Submitted With Error

Right now if i submit my form and there is an error it just shows there is an error, without reselecting the project there was an error for, (the page is called 'change project') h

Solution 1:

You are "mixing" the server side with the client side. When you use javascript you're programming on the client side and you can´t access variables in the server. So php code will not work on javascript. In

<script> alert($_POST['categorieSelect']);
         $('#project-wijzigen').show(); 
         $(this).toggleClass('close'); 
</script> 

you can´t access $_POST which is a server variable.

You shoud make something like this:

<?php echo '<input type="hidden" id="hidden-input" value="'.$_POST['categorieSelect'].'">'; ?>

and then, in your script:

<script> alert($('#hidden-input').val());
         $('#project-wijzigen').show(); 
         $(this).toggleClass('close'); 
</script>

Solution 2:

You can use Codeigniter validation.


Post a Comment for "Remember Selectbox Value After Form Submitted With Error"