Thursday 15 January 2015

php - format time input on form for 3 dropdown boxes -



php - format time input on form for 3 dropdown boxes -

in cakephp have got form input of type time. user selects time 3 drop downwards boxes (hrs,mins , am/pm). need user able select no time alternative called 'not available'

i have alternative select 'not available' user has alternative of not specifying time. works shown below.

i have drop downwards box of time , needed select not available alternative on hour. instead of selecting not available on min dropdown box , am.pm wanted min , am/pm drop boxes automatically set not available when select alternative on hour.

echo $this->form->input('mon_start', array('label'=> 'start','type' => 'time', 'style'=>'width: 80px', 'empty' => 'not available', 'selected'=>$monstart));

the question little unspecific, here's unspecific answer.

you have utilize javascript, check selected value in onchange event, , set selected options other select elements based on selected value.

here's jquery based example.

js

var selects = $('.selectlr').on('change', function() { if($(this).find(':selected').val() === 'none') { selects.find('[value="none"]').prop('selected', true); } });

html

<select class="selectlr"> <option value="none">none</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <select class="selectlr"> <option value="none">none</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <select class="selectlr"> <option value="none">none</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select>

fiddle

http://jsfiddle.net/7g97no5a/

php cakephp

No comments:

Post a Comment