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
287 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now