Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > BOOK: Beginning VB.NET Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning VB.NET Databases
This is the forum to discuss the Wrox book Beginning VB.NET Databases by Thearon Willis; ISBN: 9780764568008
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 24th, 2005, 09:48 AM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch14 - timesheets with one row

If the timesheet only has a single row, the function Recalculate doesn't work, as txtMondayHours is not treated as an array, so doesn't have a .length property. Tabbing from the last entry also fails, as txtMondayHours[0] does not exist (not an array)
I've modified the code as follows to get round this -

function Recalculate(dayofweek)
{
   //Get the number of rows
   var intCount = 0
   if (document.Form1.txtMondayHours.length > 0)
   {
      intCount=document.Form1.txtMondayHours.length;
   }

   //Find the day of the week that you are working with
   switch (dayofweek)
   {
      case "Monday":
         //Set the current total to 0 as it will be recalculated
         document.Form1.txtMondayTotal.value = 0;
         //Process each row of data adding it to the total
         if (intCount == 0)
         {
         document.Form1.txtMondayTotal.value =
         parseInt(document.Form1.txtMondayHours.value);
         break;
         }

         for (i=0;i<intCount;i++)
         {
            document.Form1.txtMondayTotal.value =
               parseInt(document.Form1.txtMondayTotal.value) +
               parseInt(document.Form1.txtMondayHours[i].value);
         }
         break;
       case "Tuesday":
         etc...
         etc...
   }
}

function tabSelect()
{
   if (document.Form1.txtMondayHours.length > 0)
   {
      document.Form1.txtMondayHours[0].select();
        document.Form1.txtMondayHours[0].focus();
   }
   else
   {
         document.Form1.txtMondayHours.select();
        document.Form1.txtMondayHours.focus();
   }
}

in TimeSheet.aspx.vb>>>>>>>>

Public Sub DisplayTimeSheet()
...
...
       'Write the total row
...
...
        Response.Write("<td><INPUT type=""text"" name=""txtMondayTotal""" & _
             "class=""TransparentTextBox"" readonly " & _
             "onfocus=""javascript:tabSelect();"" value=""" & _
             objTimeSheetDS.Tables("TimeSheet").Rows(intIndex). Item( _
             "MondayHours") & """></td>" & ControlChars.CrLf)
...
...



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
My VB Code for Ch14 PatFrank BOOK: Beginning ASP.NET 2.0 and Databases 8 April 17th, 2007 03:34 PM
Ch14 Add New Event Does Have Errors Manib75 BOOK: Beginning ASP.NET 1.0 2 March 24th, 2005 11:01 AM
Ch14 Calendar not working with Visual Studio kwalder BOOK: Beginning ASP.NET 1.0 0 November 14th, 2003 10:33 PM



All times are GMT -4. The time now is 10:40 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.