Solved

Business Open and Close hours for each day of the week - how best to structure in the database using ASP and javascript

Posted on 2013-01-27
1
307 Views
Last Modified: 2013-05-08
I'll be using this code for a timepicker so businesses can select their hours of business for each day of the week:

<input name="time" value="" />
<script type="text/javascript">
    $(document).ready(function(){
        $('input[name="time"]').ptTimeSelect();
    });
</script>

Open in new window


I need to know the best way to structure this in the ClientAdverts table: i.e. how best to store the business opening and closing hours from Monday - Sunday.

Can this be done in one field? E.g. An 'OpenHours' field containing all the open and close times from Monday - Sunday for each business listing?

The the data will need to be listed separately/vertically for each day of the week, e.g:

Monday: 08.30 - 17.30
Tuesday: 08.30 - 17.30
Sunday: Closed

Etc.

Some help and suggestions would be great.
0
Comment
Question by:UName10
1 Comment
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 38824478
The only difference between this

<input name="time" value="" />

and this

<input name="time" value="" />
<script type="text/javascript">
    $(document).ready(function(){
        $('input[name="time"]').ptTimeSelect();
    });
</script>

is the second version creates the  popup.  

Think of the javascript as this

<%
for each input with name = "time"
     make a cool pop up when the user clicks the field
next
%>

Knowing that, I would change

$('input[name="time"]').ptTimeSelect(); to

to

$('.timepicker').ptTimeSelect();

Now you have

<%
for each input that has a class of timepicker
     make a cool pop up when the user clicks the field
next
%>

and that one piece of javascript will work if you have multiple fields that need the pop up like below regardless of the ID or name.

<input name="time" class="timepicker" value="" />
<input name="time2" class="timepicker" value="" />
<input name="time3" class="timepicker" value="" />
<input name="time4" class="timepicker" value="" />
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Link Anchor Not working 9 49
How to remove a section of the main menu from Magento 1.9.3 3 30
modify change color of text 9 37
AngularJS: ng-repeat 25 26
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question