Issue
I have zero knowledge in php and would really appreciate your help. I have this code where I want the drop down field to show values from 08 to 17 (so: 08,09,10,11,12,13,14,15,16,17). Now is displaying from 00 to 17. Can somebody help me fix this?
This is the code:
// hours
$string .= ' <option value=""></option>' . "\n";
$tf_hours = (self::$form_options['time_format'] == '24') ? '17' : '12';
for ( $keyi = (self::$form_options['time_format'] == '24') ? 0 : 1; $keyi <= $tf_hours; $keyi++ ) {
$keyi = sprintf( "%02d", $keyi );
if ( self::$form_content[$field['slug']]['h'] != '' ) {
if ( self::$form_content[$field['slug']]['h'] == "$keyi" ) {
$selected = ' selected="selected"';
}
}
$string .= ' <option value="' . esc_attr( $keyi ) . '"' . $selected . '>' . esc_html( $keyi ) . '</option>' . "\n";
$selected = '';
}
$string .= " </select>:\n <select ";
$string .= ($field['input_css'] != '') ? self::convert_css( $field['input_css'] ) : self::get_this_css('select_style');
$string .= ' id="fscf_field' . self::$form_id_num . '_' . $key . 'm" name="' . $field['slug'] . '[m]">' . "\n";
$selected = '';
Solution
Change
for ( $keyi = (self::$form_options['time_format'] == '24') ? 0 : 1; $keyi <= $tf_hours; $keyi++ )
to
for ( $keyi = (self::$form_options['time_format'] == '24') ? 8 : 9; $keyi <= $tf_hours; $keyi++ )
Answered By - David
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.