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
298 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now