How To Get The Current Date And Time After A User Select Action
I spent time learning Rails and now I'm working on a demo project. I want the user to select whether or not they need immediate care on a care request _form. If the user selects
Solution 1:
First, you need to name your "immediate care" select field, and supply values for options:
<select class="form-control edit" name="immediate_care">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
Then, you need to check the selected value and set current date & time values if the value is "yes" (maybe a before_filter inside a controller):
if params[:immediate_care] == 'yes'
current_time = Time.now
params[:start_time] = current_time.strftime '%l:%m %p'
params[:start_day] = current_time.strftime '%d/%m/%y'
end
Please keep in mind, that's a simplified example, since you did not provide more details about your code.
Post a Comment for "How To Get The Current Date And Time After A User Select Action"