Monday, 9 January 2017

php - On submit, echo 'selected' on the right option of a select tag if form return false

Answer


Answer




I got an issue right now, and I really don't understand why, lol. Let me explain it!



What I want to do : If form has been submitted and return false, take "correct" values within the form and place it into his right input value so that the customer won't fill it again. (In this situation, it's about a select tag with many options)




What it's doing : Well, when I click on submit, my option selected it's ALWAYS the value 3 (5 ans et plus) but when I try to echo out $_POST['depuis'], it is the right value that echos out.



Here's my partial script :










Answer



Replace




if(isset($_POST['depuis']) == '0')


with



if(isset($_POST['depuis']) &&  $_POST['depuis'] == '0')


and so on...


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...