Solved

Reload Parent Form

Posted on 2004-04-19
24
551 Views
Last Modified: 2008-02-01
I currently have a main form that has some form input boxes and a listbox and a button on it.  What I want the user to do is click on the button which would open a modal page, they select an item from that page, the modal form then closes and the selected item is added to the listbox. I would like them to be able to add as many items to the listbox as they require.  I can't refresh the main page because other entries may have been made to other input boxes.  I also wouldn't mind being able to pass the listbox contents to the modal form to not show items already selected.
As far as I can tell I would have to use inline forms or <div> tags.  I'm not too sure.

Any ideas or better ways to perform the above action would be appreciated.

Sorry about the lack of points, I'm starting to run low.
Thanks
Drizzt
0
Comment
Question by:Drizzt95
  • 13
  • 11
24 Comments
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10865385
I decided to give this question a go as I'd not come accross this sort of thing before - and what do you know - it worked surprisingly well.

I have a main form 'Main.htm' and a modal page 'Modal.htm' The main form contains a dropdown which starts of empty - there is an 'Add' link which opens the modal window. This gives you another dropdown that you can select from - I found a cunning way to pass it back to the main window - by passing the value to a hidden field and then invoking on onFocus which then took the value and added it to the dropdown in the main window (could not add directly to the main dropdown whilst the modal window was open. The modal window then closes. When selecting another item previously selected items are filtered out so they cannot be chosen again :)


Main.htm ====================================================================================================================
<html>
<head>
<title>Main</title>
<script language="JavaScript">
<!--
function AddItem(Value)
      {
            var count = (document.List.f_0.length - 1) + 1
            var items = Value.split("|");
            
            document.List.f_0.options[count] = new Option();
            document.List.f_0.options[count].value = items[0];
            document.List.f_0.options[count].text = items[1];
      }
      
function CheckStuff()
      {
            if(document.List.f_2.value!='')
                  {
                        AddItem(document.List.f_2.value)
                        document.List.f_2.value = ""
                  }
      }
      
//-->
</script>
</head>
<body onFocus="CheckStuff()">
<form name="List" method="post" action="Main.htm">
      <input type="hidden" name="f_2" value="" onChange="AddItem(this)">
      <select name="f_0">
      </select>
      [<a href="javascript:void(0)" onClick="window.open('Modal.htm','Selection','width=300,height=200'); return false">Add</a>]
</form>
</body>
</html>
==========================================================================================================================

Modal.htm ===================================================================================================================
<html>
<head>
<title>Modal</title>
<script language="JavaScript">
<!--
var list = Array(6)

list[0] = "23|Peter"
list[1] = "35|Roger"
list[2] = "12|Simon"
list[3] = "2|David"
list[4] = "16|Clayton"
list[5] = "89|James"
list[6] = "17|John"

function LoadList()
      {
            var i
            var ii
            var check
            var count = 0
            var noitems = list.length
            var pnoitems = window.opener.document.List.f_0.length - 1
            
            
            document.Choice.f_1.length = 0;
            document.Choice.f_1.options[0] = new Option();
            document.Choice.f_1.options[0].value = "";
            document.Choice.f_1.options[0].text = "Please select.";
            
            for(i=1; i<= noitems; i++)
                  {
                        check = false;
                        var items = list[i-1].split("|");
                        
                        for(ii=0; ii<=pnoitems; ii++)
                              {
                                    if(window.opener.document.List.f_0.options[ii].value==items[0])
                                          {
                                                check = true
                                          }
                              }
                        
                        if(check==false)
                              {
                                    count++
                                    
                                    document.Choice.f_1.options[count] = new Option();
                                    document.Choice.f_1.options[count].value = items[0];
                                    document.Choice.f_1.options[count].text = items[1];
                              }
                  }
      }

function PostBack(Object)
      {
            window.opener.document.List.f_2.value = Object.options[Object.selectedIndex].value + "|" + Object.options[Object.selectedIndex].text;
            window.close();
      }

//-->
</script>
</head>
<body onLoad="LoadList()">
<form name="Choice" method="post" action="Modal.htm">
      <select name="f_1" onChange="PostBack(this)">
      </select>
</form>
</body>
</html>
==========================================================================================================================

In my example I have hardcoded my data - this info can be dynamically written from you recordset in approximately the following fashion....

<%'Dynamically Create Array Items...
Response.Write "<script language='JavaScript'>" & vbCRLF
Response.Write "<!--" & vbCRLF
Response.Write "      var list = new Array(" & rsList.RecordCount & ");" & vbCRLF & vbCRLF
For iLp = 0 to UBound(sList)
Response.Write "      list[" & iLp & "] = '" & rsList("ID") & "|" & rsList("Name") & "';" & vbCRLF
Next
Response.Write "//-->" & vbCRLF
Response.Write "</script>" & vbCRLF
%>
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10865579
Brilliant, exactly what I was after.
I'll close the question as soon as I implement it late this afternoon, just in case I have any problems with the code (it looks pretty straight forward at first glance).

Thanks for your help.
Drizzt
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10875100
Just 2 more quick questions (I'll add a few more points for helping out):

The first one is easy.
How do I change <select name="f_1" onChange="PostBack(this)"> to be called by a button instead of by an onChangeEvent.

The other one, which may be a bit harder, is how would I make the combo box in the modal form show the item that has been selected after they select an item and then click submit and post it back on itself.  
Basically it will be a two step process, they select a room from the combo, click a button which then checks the availability of the room, then they click another button to close the form.
I've got most of it working, just not the two things mentioned above.

Thanks again for your help,
Drizzt
0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10875142
I'm goning to produce an example which in effect queries the db returning only available rooms and then populates the combo - this way there is no need to keep quering for availability each time a selection is made - sound ok to you>
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10875289
No, I did start to do it that way, but then I wanted the ability for the user to first enter a date, then click add to add a location, then click Check Availablity, which would then give them two combos with times in them only showing them times that are available; Start Time and Finish Time.  They select a Start Time, which then refreshes the finish time to only show finish times that are available based on the start time selected, and the start time of the next meeting that someone else has already booked.
Excuse me while a take a breath.  

It sounds confusing (and it is) but I figured this way to be the best for ease of use for the user.  It has been very complicated to code, but works very smoothly and is easy to use.  I have all of it working so far except what I mentioned above, and boy am I happy with it.  Even with someones help, I didn't think I could produce something that worked so well and smoothly.
0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10875347
Ok, just to get things clear - please correct me where I'm wrong...

Step 1:
---------------------------------------------------------
The window opens...
The user enters a date and selects a location...
The user clicks 'Check Availbility'

Step 2:
---------------------------------------------------------
A list is displayed of the 'Start' times that are available....
This then lists available 'Finish' times in another listbox....
The user click 'Accept'

Step 3
---------------------------------------------------------
Something is posted back to the main window...
The window closes...

I've assumed a few things so if you could clear that up first it would help to understand the flow of things - cheers.
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10875426
All right except the date, it has to be entered before the window opens.  The reason for that is I will have to eventually add the ability to select multiple dates, then pass the multiple dates to the modal form, and query available times based on those dates.
0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10875496
Bare with me - I'm not quite getting this, need to clear up a few things so I understand better.

The Start time and Finish time in separate lists - I'm assuming that if I select a Start time it displays a Finsh time that corresponds to the Start time. This implies that the Finish time is already associated with the Start time - if this is the case there is no need for 2 listboxes, just have the 1 displaying the available slot, e.g. 09:00 - 11:30. I say this because if I chose 09:30 then 11:30 wil appear in the Finish times list according to your description - so I ask how do you know the 09:30 Start time has a Finish time of 11:30.

Hopefully you will see what I'm getting at - pls advice...
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10875557
No probs,

The reason for two combos, is that I don't want to only show available slots, I want them to pick a start time, the form refreshes with the list of available finish times, the user then selects a finish time.  The combo boxes show times in intervals of 15 min.

e.g.
The Main room has already been booked out between 12:15 and 4:15
 
When the user selects the Main room and clicks the button, the Start Time combo box is populated with times from 7:00 am to 12:00pm and 4:15 pm to 6:00pm in 15 minute intervals.

The user then selects 9:00am, the Finish Time combo is then populated with times from 9:15am to 12:15pm.

They click finish and the Room ID, Start Time and Finish Time is passed back to the main form.

---------------------------------
The coding that I had to use for this type of scenario was extremely confusing.

That may help a little more.


0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10875873
Ok - I understand what it is you are trying to do.
0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10875992
Now that you've introduced the addition of the Start and Finish times I would like to ask the relevance of storing the selected Rooms (Locations) in the lisbox on the main page and the checking or exclusion from the Rooms (Locations) in the listbox in the modal window.

By passing the Start and Finish time back to the main window I take it that this information then becomes part of a single record - so why the need for a list continaing multiple Rooms (Locations) if they are checking the availability of a single room.

Hope you don't mind me asking - the clearer things are the better my approach to the problem is.
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10876842
No, I don't mind at all, the more you talk about something, the more you confirm your idea, or find flaws/improvements with it.

Yep, that's where the difficulty came in.  They sometimes require that a meeting can be in two or three different rooms at the same time (i.e. partitioned rooms, same meetings shared across several rooms), and they would prefer not to have to create meetings several times. Just to make life easy!!!
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10877946
I'm currently working on something - but I have a question...

How does the user know that they will require more than one room?
0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10882661
Hi - long time - but I've been busy prepping something for you.

Go to the following location - I've placed a working example online.

http://www.internection.co.uk/Room_Scheduler

Notes:

I have hardcoded a data.
The data is pulled from a db thathas a small amount of sample data in it.

Grey boxes mean a space
Red boxes mean booked

When you select it will turn blue / click again to deselect.

Basically its at a stage where I just need to decide how to send all the data - you can choice multiple rooms and set a different Start / Finish for each room - have a look, have a play.

The idea is to allow the user to see the sceduled places (which can't be picked) - the onus is then on the user to schedule the same time slots across 2 different rooms - you'll see what i mean when you have a go.

Hope you like it - I certainly do :)

0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10882745
Er, the ...hardcoded a data, should date (which would be collected from the main window - when we get that far.
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10883571
I can see you enjoy this sort of thing, I know the more I learn about it the more I enjoy it.

Very impressive, easy to use and visually appealing for a user.  I didn't like the idea of a combo box with times, the sliding scale like you have was my preferred way, but I had no idea where to start.  I definately like it.

The problem with multiple rooms; well i was going to select a room, then only make available adjoining rooms to add as extras, etx.  Then I was told that sometimes they would occasionaly hold meetings in seperate rooms that are not adjoining.  So what I though is where you have the name Room 1 after the user has selected the room, is to have a short description about the room (ie adjoining rooms, number of people the room can fit, etx).
I would also just add a remove link to remove a room from the list after is has been added.

By the way, I've added pretty much the rest of my points for this, you've gone way beyond 250 points.

0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10884005
Ok, I've updated it - it now includes a Places / Description and I've added a 'Remove'

http://www.internection.co.uk/Room_Scheduler
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10884119
I may be pushing it, but what do you think of this:

If a user is viewing more than one room, when they select a time frame it gets added to all the rooms that are being viewed.  This may be a little difficult because of different available times across the different rooms.

Even without that, it's exactly what I need.
0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10884169
I thought about the one set of times across all the rooms and decided that it was too difficult (for me), thats why I went for displaying any selected rooms, then at least that way the user has a visual aid.
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10884240
Looking at what you've done I didn't think anything was too hard, but like I said, it's great the way it is, still very easy to use.  I could even just add a prompt after they submit it saying are you aware that you have selected different times across the rooms.  Achieves the same result, but a hell of a lot easier to code.

Posting the data back to the main form is the easy part, I'll just use your original code to post it back.

Thanks for your help, the code you've written is easy to read, so I think I'll spend a few hours going through it to understand it fully.
0
 
LVL 6

Accepted Solution

by:
Lord_McFly earned 500 total points
ID: 10884389
Pages....

DisplaySchedule.asp =============================================================================================================
<%@ Language=VBScript %>
<%Option Explicit%>
<%Response.Buffer = True%>
<!-- #include file="Functions.asp" -->
<%
Dim rsRoom
Dim sDate, sDay
Dim iRoomID, iDivCount, iSegment, iRoomNo, iSlotNo
Dim bIsTime

Const DAY_SIZE = 480
Const DAY_DIV = 15
Const RATIO = 1.5
Const DAY_START = "09:30"
Const DAY_END = "17:30"

sDate = "01/01/2004"

OpenDB

Set rsList = Server.CreateObject("ADODB.RecordSet")
sQuery = "SELECT * " &_
             "FROM Booking INNER JOIN Room ON Room.ID = Booking.RoomID " &_
             "WHERE DATEDIFF('d',RoomDate,'" & sDate & "') = 0 " &_
             "ORDER BY Room ASC, StartTime ASC, EndTime ASC"
'Screen(sQuery)
rsList.Open sQuery, objCon

Set rsRoom = Server.CreateObject("ADODB.RecordSet")
sQuery = "SELECT * " &_
             "FROM Room " &_
             "ORDER BY Room ASC"
rsRoom.Open sQuery, objCon

CloseDB
%>
<html>
<head>
<title>Schedule</title>
<link rel="stylesheet" type="text/css" href="main.css">
<script language="JavaScript">
<!--
function Display(List)
      {
            if(List.options[List.selectedIndex].value!='')
                  {
                        document.getElementById("Room_"+List.options[List.selectedIndex].value).style.display=""
                        List.selectedIndex = 0
                  }
      }

function SetTime(RoomNo, TimeA, TimeB, EndTime, SlotNo)
      {
            if(eval("document.Room.f_0_"+RoomNo+".value==''"))
                  {
                        eval("document.Room.f_0_"+RoomNo+".value=TimeA")
                        
                        var parts = TimeA.split(":")
                        var mins = parts[0] * 60 + parts[1]
                        eval("document.Room.StartTime_"+RoomNo+".value=mins")
                        eval("document.Room.StartSlot_"+RoomNo+".value=SlotNo")
                        document.getElementById("Slot_"+RoomNo+"_"+SlotNo).style.backgroundColor="#8D8FF1"
                        
                        var parts = EndTime.split(":")
                        var mins = parts[0] * 60 + parts[1]
                        eval("document.Room.EndTime_"+RoomNo+".value=mins")
                  }
            else
                  {
                        var start = parseInt(eval("document.Room.StartTime_"+RoomNo+".value"))
                        var end = parseInt(eval("document.Room.EndTime_"+RoomNo+".value"))
                        
                        var parts = TimeA.split(":")
                        var mins = parts[0] * 60 + parts[1]

                        if(mins<start)
                              {
                                    alert("Slot before or same as Start Time");
                              }
                        else
                              {
                                    if(mins>end)
                                          {
                                                alert("Would overlap existing booking")
                                          }
                                    else
                                          {
                                                if(eval("document.Room.f_1_"+RoomNo+".value!=''")&&parseInt(eval("document.Room.StartSlot_"+RoomNo+".value"))==SlotNo)
                                                      {
                                                            var i
                                                            
                                                            for(i=parseInt(eval("document.Room.StartSlot_"+RoomNo+".value")); i<=parseInt(eval("document.Room.EndSlot_"+RoomNo+".value")); i++)
                                                                  {
                                                                        document.getElementById("Slot_"+RoomNo+"_"+i).style.backgroundColor="#EEEEEE"
                                                                  }
                                                                  
                                                            eval("document.Room.StartTime_"+RoomNo+".value=''")
                                                            eval("document.Room.EndTime_"+RoomNo+".value=''")
                                                            eval("document.Room.StartSlot_"+RoomNo+".value=''")
                                                            eval("document.Room.EndSlot_"+RoomNo+".value=''")
                                                            eval("document.Room.f_0_"+RoomNo+".value=''")
                                                            eval("document.Room.f_1_"+RoomNo+".value=''")
                                                      }
                                                else
                                                      {
                                                            var i
                                                
                                                            for(i=parseInt(eval("document.Room.StartSlot_"+RoomNo+".value")); i<=parseInt(eval("document.Room.EndSlot_"+RoomNo+".value")); i++)
                                                                  {
                                                                        document.getElementById("Slot_"+RoomNo+"_"+i).style.backgroundColor="#EEEEEE"
                                                                  }

                                                            eval("document.Room.f_1_"+RoomNo+".value=TimeB");
                                                            eval("document.Room.EndSlot_"+RoomNo+".value=SlotNo");
                                                                        
                                                                  
                                                            for(i=parseInt(eval("document.Room.StartSlot_"+RoomNo+".value")); i<=SlotNo; i++)
                                                                  {
                                                                        document.getElementById("Slot_"+RoomNo+"_"+i).style.backgroundColor="#8D8FF1"
                                                                  }
                                                      }
                                          }
                              }

                  }
      }
      
function CleanUp(RoomNo)
      {
            for(i=parseInt(eval("document.Room.StartSlot_"+RoomNo+".value")); i<=parseInt(eval("document.Room.EndSlot_"+RoomNo+".value")); i++)
                  {
                        document.getElementById("Slot_"+RoomNo+"_"+i).style.backgroundColor="#EEEEEE"
                  }
                  
            eval("document.Room.f_0_"+RoomNo+".value=''")
            eval("document.Room.f_1_"+RoomNo+".value=''")
            eval("document.Room.StartTime_"+RoomNo+".value=''")
            eval("document.Room.EndTime_"+RoomNo+".value=''")
            eval("document.Room.StartSlot_"+RoomNo+".value=''")
            eval("document.Room.EndSlot_"+RoomNo+".value=''")
            
            document.getElementById("Room_"+RoomNo).style.display="none"
      }
//-->
</script>
</head>
<body>
<table width="300" cellspacing="0" cellpadding="2" border="0" class="Normal">
      <tr>
            <td width="50">Me:</td>
            <td width="250"><b>Peter Roome</b></td>
      </tr>
      <tr>
            <td>Email:</td>
            <td><b>peter@internection.co.uk</b></td>
      </tr>
      <tr>
            <td>MSN:</td>
            <td><b>proome@hotmail.com</b></td>
      </tr>
      <tr>
            <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
            <td colspan="2">Please feel free to contact me regarding this.</td>
      </tr>
      <tr>
            <td colspan="2" height="30">&nbsp;</td>
      </tr>
</table>
<table width="775" cellspacing="0" cellpadding="2" border="0">
      <form name="Room" method="post" action="<%=GetPageName%>">
            <tr>
                  <td>
                        <table width="775" cellspacing="0" cellpadding="0" border="0" class="Normal">
                              <tr>
                                    <td width="125" height="30"><b>Select A Room:</b></td>
                                    <td width="650">
                                          <%If rsRoom.EOF then
                                                Response.Write "No rooms"
                                          Else%>
                                                <select name="f_0" onChange="Display(this)" class="ListBox">
                                                      <option value="">Please select.</option>
                                                      <%Do while not rsRoom.EOF%>
                                                            <option value="<%=rsRoom("ID")%>"><%=rsRoom("Room")%></option>
                                                            <%rsRoom.MoveNext
                                                      Loop%>
                                                </select>
                                          <%End If%>
                                    </td>
                              </tr>
                              <tr><td colspan="2"><hr width="100%" noshade></td></tr>
                        </table>
                  </td>
            </tr>
            <%If not rsList.EOF then
                  iRoomID = 0
                  iRoomNo = 0
                  Do while not rsList.EOF
                        iRoomID = rsList("RoomID")
                        iRoomNo = iRoomNo + 1%>
                        <tr>
                              <td colspan="2" align="center">
                                    <table width="<%=DAY_SIZE * RATIO%>" cellspacing="0" cellpadding="0" border="0" style="display: none" ID="Room_<%=iRoomID%>" class="Normal">
                                          <tr>
                                                <td>
                                                      <table cellspacing="0" cellpadding="2" border="0">
                                                            <tr>
                                                                  <td valign="top">
                                                                        <table width="300" cellspacing="0" cellpadding="2" border="0" class="Normal">
                                                                              <tr>
                                                                                    <td width="100" height="25"><b>Room Name:</b></td>
                                                                                    <td width="200"><%=rsList("Room")%></td>
                                                                              </tr>
                                                                              <tr>
                                                                                    <td height="25"><b>Capacity:</b></td>
                                                                                    <td><%=rsList("Spaces")%></td>
                                                                              </tr>
                                                                              <tr>
                                                                                    <td height="25"><b>StartTime:</b></td>
                                                                                    <td>
                                                                                          <input type="text" name="f_0_<%=iRoomNo%>" value="" class="Box37" readonly>
                                                                                    </td>
                                                                              </tr>
                                                                              <tr>
                                                                                    <td height="25"><b>End Time:</b></td>
                                                                                    <td>
                                                                                          <input type="text" name="f_1_<%=iRoomNo%>" value="" class="Box37" readonly>
                                                                                          <input type="hidden" name="StartTime_<%=iRoomNo%>" value="">
                                                                                          <input type="hidden" name="EndTime_<%=iRoomNo%>" value="">
                                                                                          <input type="hidden" name="StartSlot_<%=iRoomNo%>" value="">
                                                                                          <input type="hidden" name="EndSlot_<%=iRoomNo%>" value="">
                                                                                    </td>
                                                                              </tr>
                                                                        </table>
                                                                  </td>
                                                                  <td valign="top">
                                                                        <table width="300" cellspacing="0" cellpadding="2" border="0" class="Normal">
                                                                              <tr>
                                                                                    <td height="25"><b>Description:</b></td>
                                                                              </tr>
                                                                              <tr>
                                                                                    <td>
                                                                                          <%If Not IsNull(rsList("Details")) then
                                                                                                Response.Write Replace(rsList("Details"),vbCRLF,"<br>")
                                                                                          Else
                                                                                                Response.Write "No description available."
                                                                                          End If%>
                                                                                    </td>
                                                                              </tr>
                                                                        </table>
                                                                  </td>
                                                                  <td width="775" valign="top" align="right">
                                                                        <span style="font-family: WingDings" style="cursor: hand" title="Click to remove" onClick="CleanUp(<%=iRoomNo%>)">&#253;</span>
                                                                  </td>
                                                            </tr>
                                                      </table>
                                                </td>
                                          </tr>
                                          <tr><td height="30">&nbsp;</td></tr>
                                          <tr>
                                                <td align="center">
                                                      <table width="<%=(DAY_SIZE + DAY_DIV) * RATIO%>" cellspacing="0" cellpadding="0" border="0" bordercolor="#" class="Times">
                                                            <tr>
                                                                  <%iTempVal = DAY_DIV * RATIO * 2
                                                                  sDay = DAY_START
                                                                  For iLp = 1 to (DAY_SIZE / 2) / DAY_DIV + 1
                                                                        If iLp = (DAY_SIZE / 2) / DAY_DIV + 1 then
                                                                              iTempVal = 0
                                                                        End If%>
                                                                        <td width="<%=iTempVal%>">
                                                                              <%If iLp MOD 2 then
                                                                                    Response.Write Left(sDay,5)
                                                                              Else
                                                                                    Response.Write "&nbsp;"
                                                                              End If
                                                                              sDay = DATEADD("n",30,sDay)%>
                                                                        </td>
                                                                  <%Next%>
                                                            </tr>
                                                      </table>
                                                </td>
                                          </tr>
                                          <tr>
                                                <td align="center">
                                                      <table width="<%=DAY_SIZE * RATIO%>" cellspacing="0" cellpadding="0" border="0">
                                                            <tr>
                                                                  <%sDay = DAY_START
                                                                  iSlotNo = 0
                                                                  Do while rsList("RoomID") = iRoomID
                                                                        iDivCount = 0
                                                                        bIsTime = True
                                                                        Do while bIsTime = True
                                                                              If DATEDIFF("n",sDay,rsList("StartTime")) <> 0 then
                                                                                    iDivCount = iDivCount + 1
                                                                                    sDay = DATEADD("n",DAY_DIV,sDay)
                                                                                    
                                                                                    If DATEDIFF("n",DATEADD("n",DAY_DIV,sDay),DAY_END) <= 0 then
                                                                                          bIsTime = False
                                                                                    End If
                                                                              Else
                                                                                    If iDivCount > 0 then%>
                                                                                          <td>
                                                                                                <table width="<%=iDivCount * DAY_DIV * RATIO%>" cellspacing="0" cellpadding="0" border="0" class="Schedule">
                                                                                                      <tr bgcolor="#EEEEEE" style="cursor: hand">
                                                                                                            <%For iLp = 1 to iDivCount
                                                                                                                  iSlotNo = iSlotNo + 1%>
                                                                                                                  <td width="<%=DAY_DIV * RATIO%>"
                                                                                                                        ID="Slot_<%=iRoomNo%>_<%=iSlotNo%>"
                                                                                                                        style="border-right: 1px solid #C7C7C7"
                                                                                                                        title="Time Slot: <%=Left(DATEADD("n",-((iDivCount + 1 - iLp) * DAY_DIV),sDay),5)%>-<%=Left(DATEADD("n",-((iDivCount + 1 - iLp) * DAY_DIV)+DAY_DIV,sDay),5)%>"
                                                                                                                        onClick="SetTime(<%=iRoomNo%>,'<%=Left(DATEADD("n",-((iDivCount + 1 - iLp) * DAY_DIV),sDay),5)%>','<%=Left(DATEADD("n",-((iDivCount + 1 - iLp) * DAY_DIV) + DAY_DIV,sDay),5)%>','<%=Left(sDay,5)%>',<%=iSlotNo%>)">
                                                                                                                        &nbsp;
                                                                                                                  </td>
                                                                                                            <%Next%>
                                                                                                      </tr>
                                                                                                </table>
                                                                                          </td>
                                                                                    <%End If
                                                                                    bIsTime = False
                                                                                    iSegment = CInt(ABS(DATEDIFF("n",rsList("StartTime"),rsList("EndTime"))) / DAY_DIV)
                                                                                    sDay = DATEADD("n",iSegment * DAY_DIV,sDay)%>
                                                                                    <td>
                                                                                          <table width="<%=iSegment * DAY_DIV * RATIO%>" cellspacing="0" cellpadding="0" border="0" class="Schedule">
                                                                                                <tr bgcolor="#F4B4B4" align="center" valign="absmiddle">
                                                                                                      <%For iLp = 1 to iSegment%>
                                                                                                            <td width="<%=DAY_DIV * RATIO%>" style="border-right: 1px solid #F59595">&nbsp;</td>
                                                                                                      <%Next%>
                                                                                                </tr>
                                                                                          </table>
                                                                                    </td>
                                                                              <%End If
                                                                        Loop
                                                                        
                                                                        rsList.MoveNext      
                                                                        
                                                                        If not rsList.EOF then
                                                                              If rsList("RoomID") <> iRoomID then%>
                                                                                    <td>
                                                                                          <table width="<%=ABS(DATEDIFF("n",sDay,DAY_END)) * RATIO%>" cellspacing="0" cellpadding="0" border="0" class="Schedule">
                                                                                                <tr bgcolor="#EEEEEE" style="cursor: hand">
                                                                                                      <%For iLp = 1 to ABS(DATEDIFF("n",sDay,DAY_END)) / DAY_DIV
                                                                                                            iSlotNo = iSlotNo+1%>
                                                                                                            <td width="<%=DAY_DIV * RATIO%>"
                                                                                                                  ID="Slot_<%=iRoomNo%>_<%=iSlotNo%>"
                                                                                                                  style="border-right: 1px solid #C7C7C7"
                                                                                                                  title="Time Slot: <%=Left(DATEADD("n",(iLp - 1) * DAY_DIV,sDay),5)%>-<%=Left(DATEADD("n",(iLp - 1) * DAY_DIV + DAY_DIV,sDay),5)%>"
                                                                                                                  onClick="SetTime(<%=iRoomNo%>,'<%=Left(DATEADD("n",(iLp - 1) * DAY_DIV,sDay),5)%>','<%=Left(DATEADD("n",(iLp - 1) * DAY_DIV + DAY_DIV,sDay),5)%>','<%=Left(DATEADD("n",ABS(DATEDIFF("n",sDay,DAY_END)),sDay),5)%>',<%=iSlotNo%>)">
                                                                                                                  &nbsp;
                                                                                                            </td>
                                                                                                      <%Next%>
                                                                                                </tr>
                                                                                          </table>
                                                                                    </td>
                                                                                    <%iRoomID = rsList("RoomID")
                                                                                    
                                                                                    Exit Do
                                                                              End If
                                                                        Else%>
                                                                              <td>
                                                                                    <table width="<%=ABS(DATEDIFF("n",sDay,DAY_END)) * RATIO%>" cellspacing="0" cellpadding="0" border="0" class="Schedule">
                                                                                          <tr bgcolor="#EEEEEE" style="cursor: hand">
                                                                                                <%For iLp = 1 to ABS(DATEDIFF("n",sDay,DAY_END)) / DAY_DIV
                                                                                                      iSlotNo = iSlotNo + 1%>
                                                                                                      <td width="<%=DAY_DIV * RATIO%>"
                                                                                                            ID="Slot_<%=iRoomNo%>_<%=iSlotNo%>"
                                                                                                            style="border-right: 1px solid #C7C7C7"
                                                                                                            title="Time Slot: <%=Left(DATEADD("n",(iLp - 1) * DAY_DIV,sDay),5)%>-<%=Left(DATEADD("n",ABS(DATEDIFF("n",sDay,DAY_END)),sDay),5)%>"
                                                                                                            onClick="SetTime(<%=iRoomNo%>,'<%=Left(DATEADD("n",(iLp - 1) * DAY_DIV,sDay),5)%>','<%=Left(DATEADD("n",(iLp - 1) * DAY_DIV + DAY_DIV,sDay),5)%>','<%=Left(DATEADD("n",ABS(DATEDIFF("n",sDay,DAY_END)),sDay),5)%>',<%=iSlotNo%>)">
                                                                                                            &nbsp;
                                                                                                      </td>
                                                                                                <%Next%>
                                                                                          </tr>
                                                                                    </table>
                                                                              </td>
                                                                              <%Exit Do
                                                                        End If
                                                                  Loop%>
                                                            </tr>
                                                      </table>
                                                </td>
                                          </tr>
                                          <tr><td>&nbsp;</td></tr>
                                          <tr><td><hr width="100%" noshade></td></tr>

                                    </table>
                              </td>
                        </tr>
                  <%Loop
            End If%>
      </form>
</table>
</body>
</html>
==========================================================================================================================

main.css ====================================================================================================================
.Times
{
FONT-SIZE: 6pt;
COLOR: #000000;
FONT-FAMILY: Verdana;
TEXT-DECORATION: none;
}

.Normal
{
FONT-SIZE: 8pt;
COLOR: #000000;
FONT-FAMILY: Verdana;
TEXT-DECORATION: none;
}

.Schedule
{
FONT-SIZE: 11pt;
COLOR: #000000;
FONT-FAMILY: Verdana;
TEXT-DECORATION: none;
}

.Box37
{
    FONT-SIZE: 8pt;
    FONT-FAMILY: Verdana;
    COLOR: #000000;
    BACKGROUND-COLOR: #FFFFFF;
    BORDER-RIGHT: 1px solid;
    BORDER-TOP: 1px solid;
    BORDER-LEFT: 1px solid;
    BORDER-BOTTOM: 1px solid;
    WIDTH: 37px
}

.ListBOx
{
    FONT-SIZE: 8pt;
    FONT-FAMILY: Verdana;
    COLOR: #000000;
    BACKGROUND-COLOR: #FFFFFF;
}
==========================================================================================================================

Functions.asp =================================================================================================================
<%
Dim objConn, objCon
Dim obj, objFSO, objFolder, objFile, objRead, objWrite
Dim objMail
Dim rsList, rsChck, rsTemp, rsDrop
Dim sTempStr, sTmpStr, sQuery, sContent, sErrMsg, sArray, sTempArray
Dim sClean, sClickMe
Dim iTempVal, iTmpVal, iLp, iLoop, iCount, iCounter
Dim iPageNo, iPrev, iNext
Dim bTemp

'== Initiate Database ================================================================================
Sub OpenDB
      Set objCon = Server.CreateObject("ADODB.Connection")
      objCon.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "\Room_Scheduler\DataDB.mdb"
End Sub
'=====================================================================================================


'== Close Database ===================================================================================
Sub CloseDB
      Set objConn = Nothing
End Sub
'=====================================================================================================


'== Returns The Name Of The Page =====================================================================
Function GetPageName
      If InStr(1,Request.ServerVariables("SCRIPT_NAME"),"/") then
            GetPageName = Right(Request.ServerVariables("SCRIPT_NAME"),Len(Request.ServerVariables("SCRIPT_NAME"))-InStrRev(Request.ServerVariables("SCRIPT_NAME"),"/"))
      Else
            GetPageName = Request.ServerVariables("SCRIPT_NAME")
      End If
End Function
'=====================================================================================================


'== Used To Debug ====================================================================================
Sub Screen(PrintThis)
      Response.Write PrintThis & "<br>"
End Sub
'=====================================================================================================
%>
==========================================================================================================================
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10885554
I just have two small problems, one is that the times are showing up as 12 hour times and that is screwing everything up.  I'm assuming that is a setting on our server, but I can't change it.
The other is that if I select a room that has no bookings yet it throws an error.

I've been trying to work them out myself, but I've got no idea.
0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10885593
Times ~ you say you can't change it. Where will the app be running ~ intranet / interest / space provided by a 3rd party - I don't know if this is going to be a difficult one to over come - in all honestly I have never in the 6 years doing web apps had to use a 12 hrs clock :)

Errors ~ always make a note of the exact error, an error description, line number and page name is given - these help to identify the problem easier.

Displaying days with no bookings ~ the code has got to the stage of listing empty days yet - you must be getting you data in a different fashion to me - you need to explain how you are doing this.

:)
0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10885687
I got around the time problem, I added formatdatetime( , vbshorttime) to a few spots.
We're running it on an intranet, and I can't change any of the existing settings.

Days with no bookings:
I haven't changed the code except to add different SQL statements.  It is basically the same.
I get the following error:

Line 12
Char 21
Error Object Required

which is around
if(List.options[List.selectedIndex].value!='')
               {
                    document.getElementById("Room_"+List.options[List.selectedIndex].value).style.display=""
                    List.selectedIndex = 0
               }


It looks to me like the list hasen't been populated preperly with the roomid's.  I'm just having a bit more of a look now.

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Current Date/Time SQL Azure 12 94
Set cursor to client side 3 48
ASP VB... 7 93
Send to Print Preview database record with one click 3 36
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

707 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

16 Experts available now in Live!

Get 1:1 Help Now