John Davidson

html - How to make php if option is required in select?

0 comments
Message:


$saat=="07:30"
I'm projecting the select an option equal to its value on the screen and the user has to choose an option from here.
There are many more options with else if. I'm just posting the IF part here to ask my question.
How to write select option is required?


<?php if($saat=="07:30") {echo  '<strong> <center>  <div class="select"> <select name="koltuk" id="koltuk"><option selected="selected">Seçiniz</option> <option value="vagon1">Vagon 1 &nbsp; --> 2 Koltuk Boş</option> <option value="vagon2">Vagon 2 &nbsp; --> 10 Koltuk Boş</option> <option value="vagon3">Vagon 3 &nbsp; --> 5 Koltuk Boş</option> <option value="vagon4">Vagon 4 &nbsp; --> 3 Koltuk Boş</option> <option value="vagon5">Vagon 5 &nbsp; --> 2 Koltuk Boş</option> <option value="vagon6">Vagon 6 &nbsp; --> 2 Koltuk Boş</option> <option value="vagon7">Vagon 7 &nbsp; --> 2 Koltuk Boş</option> <option value="vagon8">Vagon 8 &nbsp; --> 3 Koltuk Boş</option> </select> <div class="select-dropdown"></div> </div><br> </center> </strong>'; }

<select name="koltuk" id="koltuk" required>

as it doesn't.



My Answer:
To make the select option required, you can add the "required" attribute to the select tag. In your code, you can modify the select tag like this:

html

© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us