Skip to content
Advertisement

Remove last empty line from select field with “for” loop wordpress

I am create a custom widget in WordPress and in the widget I try to create a select field with for loop and shows in it 10 numbers from 1 to 10.

I created BUT underneath number 10 it have an empty line.

Can you help me to remove that empty line?

this is number 10 this is an empty line under number 10

JavaScript

Advertisement

Answer

Part 1

You need to remove the last option:

JavaScript

Part 2

To display the option label with a leading 0, you can use sprintf().

See Below:

JavaScript

Simplified PHPSandbox

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement