Violet_82 89 Posting Whiz in Training

Thanks for that :-). This escaping sequence it interesting, I didn't come across that but this \|[0-9]+ escapes the '|' absolutely fine! So I'm a bit confused...

rproffitt commented: The version of powershell might be why. Note: I'm not a historian on this area. +15
Violet_82 89 Posting Whiz in Training

Hi there, I've come across an issue while trying to get all the records from a SQL database in java.
A bit of necessary introduction here.
I'm not using any framework just JDBC and the getAllBooks method is part of a REST call. The failing method is essentially doing this:
-getting the number of all records in the db;
-getting all the ids and use them to get the records, store them in an array and return that array;
Unfortunately the call generates the following error in the while loop:

SEVERE: Servlet.service() for servlet [Jersey Web Application] in context with path [/book-storage-REST] threw exception
java.lang.IllegalArgumentException: the object parameter to marshal() is not marshallable
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:280)
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:163)
    at com.sun.jersey.json.impl.provider.entity.JSONListElementProvider.writeList(JSONListElementProvider.java:145)
    at com.sun.jersey.core.provider.jaxb.AbstractListElementProvider.writeTo(AbstractListElementProvider.java:264)
    at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:302)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1510)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

Ok, the code now:

public Book[] getAllBooks()
    {
        Book[] books = null;        
        try
        {
            resultSet = statement.executeQuery(SqlStrings.SELECT_NUMBER_ALL_RECORDS);//runs "SELECT COUNT(*) from books";           
            resultSet.next();
            int dbRecordNo = resultSet.getInt(1);//get number of record
            resultSet = statement.executeQuery("SELECT books.id FROM books");//get all ids
            books = new Book[dbRecordNo];

            int i = 0;
            while(resultSet.next() && i < dbRecordNo)
            {
                int bookId = Integer.parseInt(resultSet.getString("id"));
                books[i] = getBook(bookId);         
                System.out.println();
                i++;
            }

            return books;
        } 
        catch (SQLException e)
        {
            // …
Violet_82 89 Posting Whiz in Training

thanks for taking the time to explain it. Yes, I got it now :-).
I went for solution 1 and it's all working now :-)

Violet_82 89 Posting Whiz in Training

thanks. I only closed the scanner as eclipse was somplaining about that. I remove the close statments and now everything work. However I will use only one scanner as you suggested.
Thanks

Violet_82 89 Posting Whiz in Training

Cool, thanks

Violet_82 89 Posting Whiz in Training

That could be much easier amd faster of you sorted the List (or create a sorted copy) first. Then just store every record that's equal to the previous record.

Yes, that worked perfectly.
Here is the code.
I slightly changed the collection, adding 2 duplicates and not only one (Anna is there 3 times):

studentRecords.add(new Student("Jo", "Pip", "JP000", LocalDate.of(1999,9,23), Sex.FEMALE));
        studentRecords.add(new Student("Sean", "Due", "SD230", LocalDate.of(1982,10,2), Sex.MALE));
        studentRecords.add(new Student("Bart", "Dowes", "BD333", LocalDate.of(2000,11,23), Sex.MALE));
        studentRecords.add(new Student("Tara", "Bot", "TB345", LocalDate.of(1991,9,1), Sex.FEMALE));
        studentRecords.add(new Student("Mara", "Lewart", "ML456", LocalDate.of(1988,5,23), Sex.FEMALE));
        studentRecords.add(new Student("Anna", "Clarke", "AC010", LocalDate.of(1999,1,1), Sex.FEMALE));
        studentRecords.add(new Student("Ahmed", "Mohammed", "AM222", LocalDate.of(1990,2,23), Sex.MALE));
        studentRecords.add(new Student("Dan", "Tissip", "DT599", LocalDate.of(1988,4,12), Sex.MALE));
        studentRecords.add(new Student("Frank", "Boia", "FB300", LocalDate.of(2001,8,13), Sex.MALE));
        studentRecords.add(new Student("Anna", "Clarke", "AC010", LocalDate.of(1999,1,1), Sex.FEMALE));
        studentRecords.add(new Student("Darla", "Roberts", "DR432", LocalDate.of(1979,10,10), Sex.FEMALE));
        studentRecords.add(new Student("Jo", "Pip", "JP000", LocalDate.of(1999,9,23), Sex.FEMALE));
        studentRecords.add(new Student("Anna", "Clarke", "AC010", LocalDate.of(1999,1,1), Sex.FEMALE));

then the class Student extends Comparable and overrides compareTo

public class Student implements Comparable<Student> {
....
@Override
    public int compareTo(Student o) {

        return this.name.compareTo(o.name);
    }   
}

and the main class calls the findDuplicates method which has all the logic, sorting the elements and comparing each record to the previous one as you suggested

...
public void findDuplicates() {
        duplicateRecords = new ArrayList<Student>();
        Collections.sort(studentRecords);//sorting the collection
        printDetails(studentRecords);
        System.out.println("############");
        for(int i = 1; i < studentRecords.size(); i++) {
            Student currentStudent = studentRecords.get(i);
            Student previousStudent = studentRecords.get(i - 1);
            if(currentStudent.equals(previousStudent)) {
                duplicateRecords.add(currentStudent);
            }
        }
        printDetails(duplicateRecords);

    }
    ...

This prints

Student [name=Anna, surname=Clarke, studentNumber=AC010, dob=1999-01-01, sex=FEMALE]
Student [name=Anna, surname=Clarke, studentNumber=AC010, dob=1999-01-01, sex=FEMALE]
Student [name=Jo, surname=Pip, studentNumber=JP000, dob=1999-09-23, sex=FEMALE]
Violet_82 89 Posting Whiz in Training

Hi guys,
I am having an issue finding duplicates in an arrayList.
Here is some code

        studentRecords.add(new Student("Jo", "Pip", "JP000", LocalDate.of(1999,9,23), Sex.FEMALE));
        studentRecords.add(new Student("Tara", "Bot", "TB345", LocalDate.of(1991,9,1), Sex.FEMALE));
        studentRecords.add(new Student("Mara", "Lewart", "ML456", LocalDate.of(1988,5,23), Sex.FEMALE));
        studentRecords.add(new Student("Anna", "Clarke", "AC010", LocalDate.of(1999,1,1), Sex.FEMALE));
        studentRecords.add(new Student("Frank", "Boia", "FB300", LocalDate.of(2001,8,13), Sex.MALE));
        studentRecords.add(new Student("Anna", "Clarke", "AC010", LocalDate.of(1999,1,1), Sex.FEMALE));
        studentRecords.add(new Student("Jo", "Pip", "JP000", LocalDate.of(1999,9,23), Sex.FEMALE));

This is the list of student records stored in an ArrayList.
I have to make sure that I identify the duplicates and store the duplicates in another arrayList, duplicateRecords for the sake of argument.
Now, the first thing I tried was to do something like this

public void findDuplicates() {
        if(!studentRecords.isEmpty()) {
            duplicateRecords = new ArrayList<Student>();
            for(int i = 0; i < studentRecords.size(); i++) {
                for(int j = 1; j < studentRecords.size(); j++) {
                    if(studentRecords.get(i).equals(studentRecords.get(j)) && i != j) {
                        duplicateRecords.add(studentRecords.get(i));
                    }
                }
            }
        }
        printDetails(studentRecords);
        System.out.println("############");
        printDetails(duplicateRecords);

    }                   

Which is buggy because, of course, it adds the record for Anna twice. I guess the complexity comes in if there are multiple duplicates, for example what happens if there are 3 records for Anna Clarke? In theory I'd want that to be twice in the duplicateRecords because it is a double duplicate
I can't really think of another approach though, any ideas?

Violet_82 89 Posting Whiz in Training

Eh eh, no I was wrong, I don't need to pass anything to the constructor, I can simply keep the constructors as they are and in the employee's one do this:

public Employee(String name, String surname, String dob, String type) {
        this.name = name;
        this.surname = surname;
        this.dob = dob;
        if(type != null) {
            this.type = type;
        }
        else {
            this.type = "unspecified";
        }
        employees.add(this);

    }

Noted what you said about the readClass, you're right, I will amend. Also about the try/resource I've actually never tried it, I will have a look!

Violet_82 89 Posting Whiz in Training

Right, so here is what I came up with, following your suggestions
The test class

package testClass;

import Client.Client;
import Server.Server;
import resources.Customer;
import resources.Product;

public class TestClass {

    private static Client client;
    private static Server server;
    private static Customer customer;
    private static Product product;

    public static void main(String[] args) {
        server = new Server();
        client = new Client(server);
        test();
    }
    public static void test() {
        client.get(Customer.class, 1);
        client.get(Product.class, 2);
    }

}

has the test method calling the client's get.
Client

package Client;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import Server.Server;
import resources.Customer;
import resources.Product;

public class Client {
    private Server server;
    private Customer customer;
    private Product product;

    public Client(Server server) {
        this.server = server;
    }

    public <T> T get(Class<T> class1, int ID) {
        String restRequest = class1.getSimpleName() + " " + ID; 
        String encodedRequest = "";
        try {
            encodedRequest = URLEncoder.encode(restRequest, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        String requestType = "GET";
        String typeAccepted = "Accept:application/json";
        String fullRequest = requestType + " " + encodedRequest + " " + typeAccepted;       
        server.generateJsonResponse(fullRequest);

        return (T) class1;
    }
}

The client also encodes the request and sends it to the server, well, calls a method in the Server class I should say
Server

package Server;

import java.net.URLEncoder;

import resources.Customer;
import resources.Product;

public class Server {
    private Customer customer;
    private Product product;

    private Object getResource(String type, int id) {
        switch (type) {
            case "Customer":
                return new Customer(id, "Customer_" + id);
            case "Product":
                return new Product(id, "Product_" + id);
        }
        return …
Violet_82 89 Posting Whiz in Training

That's fine :-), I'll set up the enviroment. I'll have a server package with a Client class and a server package with the Server class, then a resource package with the Customer and the Product. Once question, what do you mean when you say

(you'll need those in both the client and the server.)
Do you mean that both CLient and Server classes will have to hold an object of type Product and Customer?

Violet_82 89 Posting Whiz in Training

OK, so I've done it as above but then I added some spaces here and there, so ended up with this in the Client class (the main class is as above):

    public String constructGetRequest(String url) throws Exception {        
        String encodedRequest = URLEncoder.encode(url, "UTF-8");
        String requestType = "GET";
        String typeAccepted = "Accept:application/json";
        String fullRequest = requestType + " " + encodedRequest + " " + typeAccepted;   
        return fullRequest;
    }

which yields GET CLIENT%2F123 Accept:application/json which I guess it means, as you said earlier, that I can - if needed - split the string at the space for example.

For the second point, the json response, I removed the json objects and done with strings as you mentioned, so in the Server the getResponse method looks like this now

public String getResponse() {
    String response = "{\"" + getResourceName() + "\":{\"id\":" + getID() + ",\"" + "price\":" + getPrice() + "}}";
    return response;
}   

And thsi yields the json response {"Dummy":{"id":1,"price":9.99}}

JamesCherrill commented: Looking good! +15
Violet_82 89 Posting Whiz in Training

Hi chaps, I have a Dell XPS17, dual booting with Windows and Ubuntu on it.
I have to give it away and therefore reinstall windows. Usually, I'd format the whole HD and reinstall Windows, but I don't have the Windows CD – it wasn't dispatched with the laptop unfortunately – so I'd like to try to do everything with the Recovery partition. I checked and it appears to be there. Now, can I format the whole HD except the Recovery partition so that I reinstall windows and remove Ubuntu with some Windows' utility rather than manually formatting it?

Violet_82 89 Posting Whiz in Training

well,first of all thanks for doing that. For me, really, either way ...generally speaking, it kind of makes sense to me to allow some flexibility and I guess allowing the view to access the model isn't such a bad thing...
Going back to the application, as things currently are, my view has some knowledge of the model because it's using the model's getters to get data out of it:

public void displayStudent(StudentModel studentModel){
            System.out.println("Student is: " + studentModel.getName() + " " + studentModel.getSurname() + "\n" + "Number: " + studentModel.getNumber());
        }

So, is that it then? Are we kind of happy with this?
At the end of the day the purpose of this os for me to understand some basic concepts like MVC :-)

jkon commented: Yes , that makes perfectly sense to me +9
Violet_82 89 Posting Whiz in Training

Actually that Object.keys(jsonStringParsed)[0] isn't so good after all, because it returns the label as a string, which means that I can't use it in this fashion as I thought I would:
jsonString.Object.keys(jsonStringParsed)[0].xxxx, as it says that the keys is undefined...

EDIT: OK, I figured that out, strange syntax for me, it will now be jsonString[Object.keys(jsonStringParsed)[0]].xxxx

diafol commented: Great - you saved me a post :) +15
Violet_82 89 Posting Whiz in Training

Hi guys I wonder if you can help me with this as it's driving me absolutely crazy.
So, I have a div, in the first screenshot which looks pretty much like a scale and can be rotated right up to 45 degrees and left up to -45 degrees
arm_0.jpg

The rotation occurs when something (a div) is dropped on the arm and based on the properties of this div the rotation is worked out and takes place. Of course there can be lots of divs in the scale, but here for the sake of simplicity we'll see only one.
Now, I set some limits as you can see, because when something is dropped on this scale I need to know in which section (0,1,2) of which side of the arm, the weight is.

LL1 = $(".arm").offset().left + this.unitSize;//where unitSize is the width of section 0,1,2 etc and arm is the actual horizontal div
LL2 = this.LL1 + this.unitSize;
LR1 = $(".arm").offset().left + ($(".arm").width() / 2 + $(".pivot").width() / 2 ) + this.unitSize;//I need to make sure I exclude the pivot
LR2 = this.LR1 + this.unitSize;

So, these limits, the first time, are worked out at the beginning before the rotation takes place as part of the initialization, so when the angle is 0.
When the arm rotates though I need to recalculate them, and that's where I'm having loads of problems because, after the rotation, the coordinates of the limits …

Violet_82 89 Posting Whiz in Training

In a way it's all good to keep up with the times, but still you're essentially forcing users to fill that "matching profile". I reckon that if it wasn't mandatory I might even fill it in...properly I mean. What I'm saying is that users should really be able to bypass it rather than being forced to fill it in. Luckily on my home computer I'm still logged in, so I can still get on the forum, but when for one reason or another I will log out and have to fill the profile in I will probably give the most random and silly answers I could think of. I'm not trying to be annoying, I just really hate the idea of having to do something I don't want to in order to access the forum. And I reckon this is the kind of thing that put people off...well certainly me: if I log in onto a website and there is anything that prevents me from doing what I came in to do, that's tough, I'll leave the website. Not trying to be harsh, but I suspect that's the case for quite a few people.

Itsdigger commented: I hear ya, I was messing with a Linux distro yesterday and tried logging in and lied my way through the whole process. +0
Violet_82 89 Posting Whiz in Training

HI, I was trying to log in onto my account from another machine and I got to a page asking me to fill my Match Profile, with no way to cancel it. That doesn't seem right, what if I don't want to do that? Not sure why you guys are forcing that on users?!

rproffitt commented: Fine question. Good thing you asked as I was just about to travel. +0
Violet_82 89 Posting Whiz in Training

Here is something interesting about detach() vs remove() in jquery that happened to me.
As we know, remove() removed an element from the DOM wherease thedetach() does the same thing but it keeps all the jquery events bound to the element to which the method is applied to.
I have an application which allows users to upload and validate some files. The form sits in a popup which is triggered by a normal button on the page. When the popup is open users can upload a file (only one) using a input of type file and send it via ajax to the server when they submit the form.
The popup has a close button and when it is pressed the popup was detached using detach() from the DOM and the input field cleared. What happened was that every time I reopened the popup and upload a new file, somehow I ended up with more than one file, the one uploaded plus the other ones I uploaded before (one for each session), unless I ctrl + f5. Specifically, when I pressed the browse button, selected a file from the file system and pressed open, I would get the same file system window again, once, twice, three times, depending on home many times I had so far uploaded a file.
I replaced detach() with remove() and so not only I remove the popup from the DOM when the close button is pressed, but I also remove the associated …

Violet_82 89 Posting Whiz in Training

Hi guys, I wonder if you can help.
As I've started as a programmer, I've been told I have to practice OO a bit more. I've done the theory, but I think I will have to take another look at it. , Above all though, I have to do exercises.
What I'm looking for is for suggestions: things I have to practice are:
-Inheritance
-Interfaces
-Polymorphism
-And in general anything to do with OO.
Ideally I don't really need to do any complicated exercise, even simple scenarios would do as long as I can put into practice the theory, printing some user input strings might be enough as long as I can implement 00 principles, so things like, an emplyoee hierarchy or something along these lines.
Also I know Im a bit weak when it comes to linking different classes together, and things like composition.
So, can anybody suggest simple situation/s I could use to practice?
I have installed the Spring Tool Suite but if I'm not mistaken I can use it to create ordinary java projects.
Any idea?

Violet_82 89 Posting Whiz in Training

Right, I think I might have found the problem. Reading through the php manual, it appears that when I use the filter_input method I shouldn't put the first parameter (type) in quotes like this
$website = filter_input('POST', 'website', FILTER_SANITIZE_URL); but it should instead be $website = filter_input(INPUT_POST, 'website', FILTER_SANITIZE_URL);.
I changed all of them to be

if($_SERVER['REQUEST_METHOD'] == 'POST'){
        $firstName = filter_input(INPUT_POST, 'firstName', FILTER_SANITIZE_STRING);
        $lastName = filter_input(INPUT_POST, 'lastName', FILTER_SANITIZE_STRING);
        $emailAddress = filter_input(INPUT_POST, 'emailAddress', FILTER_SANITIZE_EMAIL);
        $message = filter_input(INPUT_POST, 'message', FILTER_SANITIZE_STRING);
        $website = filter_input(INPUT_POST, 'website', FILTER_SANITIZE_URL);
        ...

And now the data in the email comes through OK, but please let me know if you think this amendment is right :-)
thanks

cereal commented: it's ok! +14
Violet_82 89 Posting Whiz in Training

Right, I reconsidered the whole thing, as I'm clearly not really good with php and I didn't get any solution from anywhere.
I've refactored the code, and, for simplicity, mocked up a simpler form here http://antonioborrillo.co.uk/formTest/test.php (no styles or fancy animations, just a crude form). And here is what I've decided to do.
As I needed only some basic validation, I've done it clientside, and I've validated only the mandatory fields. If there is an error, meaning merely that the input field is empty as I'm not validating the email address, an error message appears at the top, the same general error message for all the fields. I used to have a customized error address for each field, but to be honest, there is probably no need for that. When the form gets submitted you get a submission message at the top of the form that disappears after 2 seconds.
Let's quickly look at the code.
HTML Form (test.php):

<!DOCTYPE html>
<html>
    <head>
        <script src="jquery-1.11.3.min.js"></script>
        <script src="form_en.js"></script>
        <link rel="stylesheet" type="text/css" href="style.css">
        <title></title>
    </head>
    <body>
        <form id="contactForm" target="_blank" method="POST" action="formhandler.php">    
            <!-- <div class="control-group">
                <label class="control-label" for="title">Title*</label>
                <div class="controls">
                    <select id="title" name="title">
                        <option value="0">Please select</option>
                        <option value="1">Mr </option>
                        <option value="2">Mrs</option>
                        <option value="3">Ms</option>
                        <option value="4">Sir</option>
                    </select>
                    <span class="error"></span>
                </div>
            </div> -->
            <div class="control-group">
                <label class="control-label" for="firstName">First name*</label>
                <div class="controls">
                    <input id="firstName" type="text" name="firstName" value="" class="mandatory">
                    <!-- <span class="error"></span>-->
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="lastName">Last name*</label>
                <div class="controls">
                    <input id="lastName" type="text" name="lastName" value="" class="mandatory">
                    <!-- <span class="error"></span>--> …
Violet_82 89 Posting Whiz in Training

I've managed to send an email finally, here is the working php script:

 <?php
  //require 'PHPMailer-master/PHPMailerAutoload.php';
  //header('Content-Type: application/json');

  $errors = array();



  $title = (isset($_POST['title']) && ($_POST['title'] != '0')) ?  $_POST['title'] : null;
  $firstName = (isset($_POST['firstName']) && !(empty($_POST["firstName"]))) ? $_POST['firstName'] : null;
  $lastName = (isset($_POST['lastName']) && !(empty($_POST["lastName"]))) ? $_POST['lastName'] : null;  
  $emailAddress = (isset($_POST['emailAddress']) && !(empty($_POST["emailAddress"]))) ? $_POST['emailAddress'] : null;
 $website = isset($_POST['website']) ? $_POST['website'] : '';
 $message = (isset($_POST['message']) && !(empty($_POST["message"]))) ? $_POST['message'] : null;

 if ($title === null) {
     $errors[] = 'You must select a title';
 }

 if ($firstName === null) {
     $errors[] = 'You must enter a first name';
     $firstNameError = "You must enter a first name";
 }

 if ($lastName === null) {
     $errors[] = 'You must enter a last name';
 }

 if ($emailAddress === null || filter_var($emailAddress, FILTER_VALIDATE_EMAIL) === false) {
     $errors[] = 'You must enter a valid email address';
 }

 if ($website !== '') {
     if(strpos($website, '://') === false) {
         $website = 'http://' . $website;
     }

     if (filter_var($website, FILTER_VALIDATE_URL, array('flags' => null)) === false) {
         $errors[] = 'You must enter a valid website address';
     }    
 }

 if ($message === null) {
     $errors[] = 'You must enter a message';
 }

 if (empty($errors)) {
     require __DIR__ . '/PHPMailer-master/PHPMailerAutoload.php';

     //SMTP needs accurate times, and the PHP time zone MUST be set
     //This should be done in your php.ini, but this is how to do it if you don't have access to that
     date_default_timezone_set('Etc/UTC');

     /* $mail = new PHPMailer;
     $mail->isSMTP();
     $mail->Host = 'smtp.gmail.com';
     $mail->Port = 587;
     $mail->SMTPSecure = 'tls'; …
Violet_82 89 Posting Whiz in Training

All done and working.

rproffitt commented: Advance +1. +0
Violet_82 89 Posting Whiz in Training

HI guys, I'm a bit puzzled about the forum area tags that appear on our profiles, screenshot here
daniweb.png
This is supposed to show you the areas of the forum where you've been posting more, but it's either inaccurate or there is something wrong with the taggin system (the old one was far better I think). It says that I've been posting more in C++ than anything else, which I'm not too sure is the case, in fact I am pretty sure that I posted more in Java than in C++ and more in Javascript than anything else (I can definitely say that Javascript has more posts than PHP), so what's going on? is the tagging system somehow inaccurate (presumably it is as inaccurate as people make it, meaning they can probably add tags that don't really match what's in the post, although in my case I'm not necessarily referring to human error as such, could it be that something has gone wrong when you switched to the new site and the wrong tags have been added to the wrong posts?)
Any idea?

Violet_82 89 Posting Whiz in Training

well, I'm not necessarily screaming at them for not giving me things for free, I'm screaming at them for not helping me, which may or may not result in them giving me a free key. Fact is, they couldn't do anything to help. Of course, lesson learned, I will make a note of the windows keys from now on (starting from my main computer) but my point is, I'm not surprised if people resort to piracy to get software if software companies don't have any way to help people if they need help. I don't care if they can't determine whether I'm lying or not, if somebody needs help and they can't give any, people will go elsewhere, it is pretty obvious.

Violet_82 89 Posting Whiz in Training

Fair enough pcbugfixer, I didn't know you were a reseller, apologies if I sounded a bit funny, it's just that when people asks for those details I think it is legitimate to feel a bit suspicious.
Let me also clarified a few points also. Samsung misunderstood the issue to an extent, I didn't replace the HD, I just formatted it, and I couldn't use any script because the formatting process had already started unfortunately (yes my fault but I was absolutely sure I had the windows key).
Why post here? Because, as said, I realized too late that I had no windows key.
The reason why I formatted it, was because I had in mind to sell the laptop, and since it came with windows xp, I wanted to put it back. But like I said, I managed to fix the screen issue which prompted me to decide to sell it in the first place, so eventually decided to keep it. Yes windows 7 is a good idea, but I don't want to buy it to be honest, that's why I put ubuntu on it.

Violet_82 89 Posting Whiz in Training

OK, I think I got there in the end. The problem wasn't in fact with any of the views I looked at, but in the index view, specifically here:

<span class="controller">@Html.ActionLink("Edit", "Edit", new { id=item.ReviewID })</span>
        <span class="controller">@Html.ActionLink("Details", "Details", new { id=item.BookID })</span>
        <span class="controller">@Html.ActionLink("Delete", "Delete", new { id=item.BookID })</span>

No wonder it was broken...I was calling up details and delete with the Book ID and not the review ID. So by changing the above into:

<span class="controller">@Html.ActionLink("Edit", "Edit", new { id=item.ReviewID })</span>
        <span class="controller">@Html.ActionLink("Details", "Details", new { id=item.ReviewID })</span>
        <span class="controller">@Html.ActionLink("Delete", "Delete", new { id=item.ReviewID })</span>

it works. Thanks for looking at the code anyway:-)!

Violet_82 89 Posting Whiz in Training

OK, I think I feel a bit like an idiot for finding my own answers only after I post the problem. Of course I don't need to iterate through the objects to check if the model is empty! D'oh!
So, here is the revised, working code.

@if (!Model.Any()) { 
    <span>Empty!</span>
}
else{
    foreach (var item in Model) {        
        <span class="header"> @Html.DisplayNameFor(model => model.BookName)</span>        
        <span>@Html.DisplayFor(modelItem => item.BookName)</span>
        <span class="header">@Html.DisplayNameFor(model => model.ISBN)</span>
        <span>@Html.DisplayFor(modelItem => item.ISBN)</span>
        <span class="header">What do you want to do with this book?</span>
        <span class="controller">@Html.ActionLink("Edit", "Edit", new { id=item.BookID })</span>
        <span class="controller">@Html.ActionLink("Details", "Details", new { id=item.BookID })</span>
        <span class="controller">@Html.ActionLink("Delete", "Delete", new { id=item.BookID })</span>
        <div class="separator"></div>
    }
}

I knew I wasn't too far off!

Violet_82 89 Posting Whiz in Training

Ah! Hold on, I cracked it, looks like I was using the parameters in the wrong order..eh eh. Here is the winning combination:
<div class="link">@Html.ActionLink("Go to Reviews", "Index", "Review")</div>
So, link text, Action, Controller!! Darn!

Violet_82 89 Posting Whiz in Training

Talked to a few people and they're saying that all that notation should be scrapped. Here's an idea, I'll do a simpler example and when I get that to work, I'll come back to this and perhaps re-write it as it seems we're not getting anywhere with this application

Violet_82 89 Posting Whiz in Training

all right, I've done some work on these darn classes as I need to progress with this.
Based on what tobyITguy and some readings I've done, I have revised the classes, hopefully we're getting closer, even if there are still things that are not clear to me. Here they are:http://pastebin.com/iLdHPQ6X
So, questions now:
1)lets's have a look at some of the classes. Take the Patient.cs:

public virtual ICollection<PatientAllergy>PatientAllergies { get; set; }
    public virtual PatientWeight Weight { get; set; }
    public virtual ICollection<Operation> Operation{ get; set; }
    public virtual ICollection<HealthCondition>ConditionName { get; set; }
    public virtual ICollection<PatientBloodTest> test { get; set; }
    public virtual ICollection<PatientExercises> exercise { get; set; }
    public virtual ICollection<PatientJab> jab { get; set; }

I've used ICollection because the relationship between the patient class and the others is either a 1-to-many or a many-to-many, and the ICollection maintains the many XXX (for example, jabs, operations etc) associated with the patient class. The PatientWeight is different bwcause the relationship is 1-2-many and so, no ICollection. Loosely correct?
2)each other class has a key token with an ID to signify primary key and a foreign key token which is PatientID, for example, take the PatientExercises:

[key]
    public int PatientExercisesID { get; set; }

    [ForeignKey("PatientID")]
    public int PatientID { get; set; }

3)Every class - except Patient of course - also has a reference to the Patient class, depending on the kind of releationship it has with it: if it is …

Violet_82 89 Posting Whiz in Training

Hi thanks for your help and the file. I had a good look at it, but to be honest I'm really confused now, and the classes are significantly different from mine, which you know, it's absolutely fine if mine are wrong, but there are things that I don't seem to understand.
Here are the points that are not making that much sense to me, sorry.
1)you said I should use the [key,ForeignKey("Patient")], but in your classes, this is never used anywhere, you only have [Key] in the PatientWeight and Patient classes;
2)I used generic collections in my classes, but you've removed them all. Take the Patient class:
public virtual List<PatientAllergy> PatientAllergies { get; set; } and all the other collections: I used them because one patient can have multiple Allergies, Operations etc, is that wrong? Still in the Patient class, PatientWeight seems to be a collection (you have it down aspublic ICollection<PatientWeight> PatientWeight { get; set; })? Why is that? There's only one weight per patient. Also is a ICollection<> different from a List<>?
3) all the ids on the Patient class:

public int PatientID { get; set; }
public int AllergyID { get; set; }
public int OperationID { get; set; }
public int HealthConditionID { get; set; }
public int PatientBloodTestID { get; set; }

Why storing them in the Patient class and then again in each single class? We essentially have them twice?
4)In each class you have a public virtual …

Violet_82 89 Posting Whiz in Training

Hello guys, I wonder if I could get some help with a project I'm planning to start. As you all probably know, I'm learning MVC and I've followed dozen of online tutorials, dipped in and out of many books but I got to the conclusion that I have to dive straight in and attempt, hopefully with the help of the community, to build a small, easy application. Obviously, if you think it is too complicated for a beginner, please do let me know.
So, what I've in mind is an application that allows users to enter their own, basic, medical record. I have an HTML version on my local machine, with some sample data. Here are some screenshots of the current version:
screenshot_1.jpg
screenshot_2.jpg

as you can see there are 5 sections:
1)Patient's general info;
2)Blood tests;
3)Jabs and injections;
4)Weight;
5)Exercises;
These last 2 are done with google graph, but I won't use that for the MVC application as it may add another layer of complication.
So, the idea is that users will be able to record all the details listed (all the data wil be saved into a Entity Framework database) and maybe log in before doing so (but I suppose I can always add that to a later date).
Starting with the models, I suppose that each of the 5 sections can be a class, correct? So, for example, let's …

Mike Askew commented: :o +7
Violet_82 89 Posting Whiz in Training

Guys, I am a little confused with the usage of the keyword model/Model in MVC, so I was hoping somebody could clarify a few aspects of it (needless to say internet searches didn't really help that much).
Given this model:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Ebuy.Website.Tests.Models
{
    public class Auction
    {
        public long Id { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public decimal StartPrice { get; set; }
        public decimal CurrentPrice { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }
    }
}

And this method in a Auction controller

public ActionResult Details(long id = 0)
        {            
            var auction = new Auction
            {
                Id = id,
                Title = "Brand new Widget 2.0",
                Description = "This is a brand new version 2.0 Widget!",
                StartPrice = 1.00m,
                CurrentPrice = 13.40m,
               // StartTime = DateTime.Parse("6-15-2012 12:34 PM"),
               // EndTime = DateTime.Parse("6-23-2012 12:34 PM"),
               StartTime = DateTime.Parse( "6-15-2012 12:34 PM", CultureInfo.CreateSpecificCulture("en-EN") ),
               EndTime = DateTime.Parse( "6-23-2012 12:34 PM", CultureInfo.CreateSpecificCulture("en-EN") ),
            };
            return View(auction);
        }         

and finally a Create view:

@model Ebuy.Website.Tests.Models.Auction

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>
@using (Html.BeginForm()) { 
    <p>
        @Html.LabelFor(model => model.Title)
        @Html.EditorFor(model => model.Title)

    </p>
    ...
}

1)when model is used at the top of a view as in @model Ebuy.Website.Tests.Models.Auction, it is pretty clear, in the sense that it's there because that is a strongly typed view and it allows to use property …

Violet_82 89 Posting Whiz in Training

I just wanted to share this with the community, in case anybody finds it useful. I'm learning ASP.NET and started with Web Forms and now I'm moving slowly to MVC. As I have just started with MVC - which is significantly different from Web Form - I've been looking for a good book/tutorial, but it has been harder than I thought. Yes I did find good books, but they all required some knowledge I didn't have. SO, eventually I stumbled across this one, "Intro to ASP.NET MVC 4 with visual studio", by Rick Anderson and Scott Hanselman, here is a link to it (the link is from the microsoft website and will download the PDF straightaway - note to mods: I could only find a direct link. ) Intro to ASP.NET MVC 4 with Visual Studio (Beta)

It's a good starting point, and then you can expand from there and get a good book.

Violet_82 89 Posting Whiz in Training

OK, I think I got it. There was no need to create a new table in the first place, facepalm, as I can simply read the results from the current tables as they WHERE filter will do the job for me!

 protected void displayLondonPrices(object sender, EventArgs e) {
        string londonPrice;
        string london_surname;
        string london_name;
        hookup = new SqlConnection("Server=localhost\\SqlExpress;Database=tests;" + "Integrated Security=True");        
        strInsert = "SELECT Name,Surname,Price FROM transactions WHERE Town='London'";
        sqlCmd = new SqlCommand(strInsert, hookup);
        hookup.Open();
        reader = sqlCmd.ExecuteReader();
        queryResults.Text = " ";
        while (reader.Read()) {            
            london_name = Convert.ToString(reader["Name"]);
            london_surname = Convert.ToString(reader["Surname"]);
            londonPrice = Convert.ToString(reader["Price"]);
            queryResults.Text += "user in London is " + london_name + " " + london_surname + " and price paid is " + londonPrice + "<br />";
        }
        reader.Close();
        hookup.Close();

    }

The result returned now is:

user in London is Antonio Borrillo and price paid is 345.00
user in London is Thomas Hardy and price paid is 23.00
user in London is Hanna Moos and price paid is 345.00
Violet_82 89 Posting Whiz in Training

Sorry JeorgeM I was replying to imti321 asking for a screenshot.
Yes I remember what you said but frankly I don't remember what I did in the SQL installation, I don't remember seeing an option to install both localDB and SQLEXPRESS. However, after a bit more research I came across this http://learningsqlserver.wordpress.com/2011/01/21/what-version-of-sql-server-do-i-have/ . This is really important and the reason being that it reminded me that I have installed a single instance, so rather than attempting to connect using localhost\SQLEXPRESS (and various combinations like the one you suggested which was something like .\SQLEXPRESS - sorry can't find the post now) I used only localhost, and it worked :-)!!

Violet_82 89 Posting Whiz in Training

thanks guys, I did it eventually and not used the custom validator (as I couldn't get that to work), I managed to do everything with the range validator and the required field

Violet_82 89 Posting Whiz in Training

Hello guys, a while back I posted something about what was needed to build an overtime app that stored data permanently on the server (here is the post https://www.daniweb.com/web-development/php/threads/467433/change-content-of-html-page-with-php) and I was told to use PHP. I have to say I've never got around that, but now I'm looking into asp.net and I was wondering whether this is possible to achieve using that and perhaps SQL (I don't know how well I have to know asp.net and SQL, I can only do small and simple applications as I 'm learning how to use.)
So, I already have the html code and the script that takes care of updating cells in a table and making the necessary calculations, but this is only at the front end:

<!DOCTYPE html>
<html>
    <head>
        <title>This is a test</title>
        <link rel="stylesheet" type="text/css" href="styles.css" >
        <script src="http://code.jquery.com/jquery.js"></script>
        <script type="text/javascript" src="script.js"></script>
    </head>
    <body>
        <table>
            <tr>
                <th>Week ending</th>
                <th>Total week hours worked</th>              
                <th>Week overtime available</th>
                <th>Total overtime</th>
                <th>Comments</th>             
            </tr>
            <tr class="editable">
                <td><input type="text" class="date"></td>
                <td> <input type="text" class="hoursWorked"></td>
                <td class="overtimeAvailable"> </td>              
                <td class="totalOvertime"></td>
                <td> <textarea type="text" class="comments"></textarea></td>                
            </tr>            
        </table>
        <button>Submit</button>
    </body>
</html>



$(document).ready(function(){
    var totalOvertime = 0;
    $("button").click(function(){
        var tableRow;
        var date;
        var hoursWorked;
        var overtimeAvailable;
        var comment;
        date = $("input.date").val();
        //console.log(date);
        hoursWorked = parseFloat($("input.hoursWorked").val());
        overtimeAvailable = hoursWorked - 37.5;
        totalOvertime += overtimeAvailable;
        comment = $(".comments").val();
        console.log(comment);
        console.log("hours " + typeof hoursWorked + " overtime " + typeof overtimeAvailable );
        tableRow = '<tr>' +
                        '<td class="date">' + date + '</td>' +
                        '<td class="hoursWorked">' + …
Violet_82 89 Posting Whiz in Training

I don't disagree with you at all, but I doubt I will ever develop something big. That said, I hope to learn the basics of layout (which will involve doing things from scratch) and then perhaps moving a GUI.

Violet_82 89 Posting Whiz in Training

Hello guys,
A few days ago I was looking on the net for a good jquery tabbed navigation – I needed it for a project – and I have to say that what I found wasn’t really what I was hoping for. An awful lot of people seem to be using plug-in (nothing wrong with that but I try to avoid them unless it is absolutely necessary), others had hundreds lines of script instead (I try to avoid that too). So not terribly satisfied with the results of my search, I thought I’d try to build one myself, using as little code as I could. Well, it turned out it wasn’t as difficult as I thought it would be. My JS is only 18 lines long which makes it very good for beginners (there are lots of comments)! So I thought it might be a good idea to share this with the community in case you are like me and you look for a very very simple, non-plug-in, tabbed navigation solution. Feel free to expand it and do whatever you want with it.
HTML:

<!DOCTYPE html>
<html>
<head>
<title>Tab test</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div class="wrapper">
<div class="smallBoxWrapper">
<div class="smallBox"></div>
<div class="smallBox"></div>
<div class="smallBox"></div>
<div class="smallBox"></div>
<div class="clear"></div>
</div>
<div class="tabbedMenu">
<ul>
<li class="active"><a href="#">Tab 1</a></li>
<li><a href="#">Tab 2</a></li>
<li><a href="#">Tab 3</a></li>
<li><a href="#">Tab 4</a></li>
<li><a href="#">Tab 5</a></li>
<li><a href="#">Tab 6</a></li>
<li><a href="#">Tab 7</a></li>
<li><a href="#">Tab 8</a></li>
</ul> …
Violet_82 89 Posting Whiz in Training

Why don't you start by removing that awful <br/> in the HTML file between the two lines?

 <div class="body_panel">
                    <h4>main body 3</h4>
                </div>
                <br />
                <div class="body_panel">
                    <h4>main body 4</h4>
                </div>

That should sort you out. Try and post back.

Violet_82 89 Posting Whiz in Training

Hello guys, I hope you can clarify something for me please.
I was looking into carousels, found an excellent one and replicated in my code (for reference this is the one I looked at, it’s really good and easy to understand https://tutsplus.com/lesson/the-obligatory-slider/).
Anyway, I have implemented that and I thought I’d do my own controllers, so I grabbed a few images and positioned them absolutely inside the container with the pictures (screenshot attached for reference).
fe2b66806a64f4f99ab98b863add69cc

Let’s have a look at some code.
This is the HTML structure. the carouselWrapper div contains the images and the controllers

<body>
<!-- carousel -->
<div class="carouselWrapper">
<ul>
<li><img src="image1.jpg"></li>
<li><img src="image2.jpg"></li>
<li><img src="image3.jpg"></li>
<li><img src="image4.jpg"></li>
</ul>
<div class="sliderNav">
<button data-dir="prev" class="left transparent"></button>
<button data-dir="next" class="right transparent"></button>
</div>
</div>

<!-- end of carousel -->

</body>

Here is the relevant CSS:
Nothing too involved, the carouselWrapper has default position:static.

.carouselWrapper{
    width:500px; /*size of the pix*/
    /* height:375px; */
    overflow:hidden;
    margin:0 auto;
}

.carouselWrapper ul{
    list-style-type: none;
    width:10000px;  

}
 .sliderNav button.right{
    background:url("controllersRight.jpg") no-repeat 0 0;
    width:48px;
    height:39px;
}
.sliderNav button.left{
    background:url(controllersLeft.jpg) no-repeat 0 0;
    width:48px;
    height:39px;
}
 .sliderNav button.left, .sliderNav button.right{
    position:absolute;
    border:0;
}

And here is the relevant part of the script that positions the two controllers. Again, nothing fancy: I get all the widths and heights I need and then update the top and left value of both the controllers.

/*positioning the controllers*/
    var containerWidth = $(".carouselWrapper").width();//get width of …
Violet_82 89 Posting Whiz in Training

Hello all, I wonder if you can help me with this. I wanted to create a page which, among the other things, has a div with a lot of text inside. Below this div there will be 2 buttons. When viewed on a mobile, the height of this div become fixed to fit the screen and the content inside becomes scrollable so that the two buttons below the div are always visible. That's all done with media queries and it works absolutely fine except for the fact that users will never know that the content in the div is scrollable because - I have just realized - mobile devices won't show scrollbars by default and in fact not even during the scrolling. I have done a bit of googling and nobody seems to suggest any pure CSS/HTML solution, maybe because there isn't. Is anybody aware of any CSS/HTML fix? If not what would be a good reliable and fairly easy to integrate plug-in that will achieve that?
Here is a screenshot from android, as you can see no scrollbars
7c2bb4a0609717892873040ed8df5e3b
Code-wise, it is a simple html page

 <html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="contentWrapper">
<div class="contentConstrained">
<div class="content">                
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nec magna dui. Proin eget lacinia augue. Quisque vel sagittis tortor. Duis fringilla magna sit amet ullamcorper posuere. Suspendisse suscipit interdum nibh. Nullam pulvinar porta nulla, …
Violet_82 89 Posting Whiz in Training

sorry, I forgot to make it solved!

Violet_82 89 Posting Whiz in Training

This should give you an idea http://css-tricks.com/snippets/css/media-queries-for-standard-devices/ although to be honest I never use that many media queries. As long as you target tablets and phones you should be ok. In terms of widths to use, I am of the opinion that the layout should dictate how many queries and what type of queries you need: in other words, if your site breaks at 940px wide, then use 940 as a trigger point for a media query. DOes it make any sense?

Violet_82 89 Posting Whiz in Training

well, not sure I can be more specific than that mate. You said you are using the grid system to create the table - at least this is my understanding - and like I said, forget about the grid system (it looks like the below)

<div class="row">
    <div class="span4"></div>
    <div class="span8"></div>
</div>

That is used to place content in the page, but it shouldn't be used to position tables on the page. Look at the table markup they have on the link I sent you:

<table>
  <caption>...</caption>
  <thead>
    <tr>
      <th>...</th>
      <th>...</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>...</td>
      <td>...</td>
    </tr>
  </tbody>
</table>

DO you see? There are no div with class of row or span, just a table. If you do that the table shouldn't break. DOes it make sense?

iamthwee commented: yup +14
Violet_82 89 Posting Whiz in Training

Hi chaps, I am looking for a not too difficult exercise which involves superclasses and subclasses (the java book I am reading doesn't really have any good one). So I was thinking about something like this:
Create a superclass 2DimensionalShapes and 2 subclasses Rectangles and Triangles. I will then need to calculate the area and perimeter of a Rectangles object and a Triangles object.
I am thinking to have the sides declared in the superclass and perhaps the methods in the subclasses, not sure what's best. Do you guys have any suggestion at all as to whether this could be a good exercise and the best way to implement it?
thanks

Violet_82 89 Posting Whiz in Training

To be honest with you @yaragalla_mural I don't like the way you have positioned the elements in your code, there is no need to position elements relatively if you can achieve pretty much the same effect with padding for the sake of argument.
Check this code out and adjust the padding to your liking (needless to say all those styles need to go in a proper external CSS, I assume you used inline styles just for demonstration purposes):

 <!DOCTYPE html>
    <html>
        <head>   </head>
        <body>
        <div style="height:50px;background:#F75D59;border:1px solid yellow">
            <div style="font:bold 20px arial;color:white;float:left;padding-left:50px">GOOGLE 
            </div>
                <div style="float:left;padding-left:40px">
                    <input type="text";text size="50px">
                    <input type="button" title="search">
                </div>
            <div style="float:left;color:white; padding-left:150px"> mythili mydhili
            </div>
            <div style="float:right">
                <input type="button" color="#ff0000"value="1">
                <input type="button" button size="10px" value="+share"> 
                <img src="a.png"height="20px";width="20px">

            </div>

        </div>



    </body>
</html>

Forgot to mention: If you're trying to achieve some sort of responsive website, you need to rethink your strategy completely and give a percentage based width to your divs

Violet_82 89 Posting Whiz in Training

Chaps I have an interesting and odd problem. Today I had the brilliant(??) idea of using google
chart https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Loading
for a site I am building. It is all nice and dandy till I placed the graph inside a hidden container,
planning to add some jquery and slide the graph down when somebody clicks a link. The functionality works,
in that the graph does actually slide down but the size of it shrunk to almost half of it. Feeling completely lost after having tried to increase the width of a few of the container created by the google script, I had a
look online and found something that perhaps explains what the problem is:
http://stackoverflow.com/questions/8577366/using-hide-and-show-with-google-visualization/8600892#8600892
In essence, when the graph is places in a hidden container, it doesn't work(!!). Now they do provide some
sort of fix, but I have failed to implement it (they say to use the call the function that draws the graph as
a callback function to the one that unhides the element, if I have understood correctly.)

Here is some html code and css to describe the issue (but you can see the problem online here http://antobbo.webspace.virginmedia.com/medical/home.html if you click on 'pulse' and compare the size of that graph to the one under exercise which at the moment for demonstration purposes resides in a block container - no hiding occurs).
This is the html exerpt where you have the empty …