php - How not to send empty input value in GET-query
575
I have a form like this
<form action="index.php">
<input type="hidden" name="id" value="1">
<input type="hidden" name="order_by" value="">
<button type="submit">Submit</button>
</form>
It has some jQuery handlers to fill in "order_by
" field.
If I submit this form with empty "order_by
" filed, I get an address like this:index.php?id=1&order_by=
What is the best way I can do to get following address after form submission if the "order_by
" is empty:index.php?id=1
?
Answer
Solution:
you can disable empty fields so they don't get added as data
Answer
Solution:
in php you can do like this
or
change html like this
javascript:
Answer
Solution:
You can disable empty fields (both select and input) so they don't get added as data, and for a custom form id.