Is this too far off topic??

Discussion in 'HTML' started by Al Jones, Jan 13, 2005.

  1. Al Jones

    Al Jones Guest

    Could I get you to take a look at www.brendasfire.com/amej/darvan.html
    andoffer suggestions before I jump off into something I can't crawl out of.

    This will be run on a local machine, the intent is that the information
    from the pop-up will be printed to a local printer.

    Basically any comments on direction will be appreciated.

    Apologies ahead of time for cross posting to both groups but I hope
    someone will offer guidance.
     
    Al Jones, Jan 13, 2005
    #1
    1. Advertising

  2. Al Jones

    RobG Guest

    Al Jones wrote:
    > Could I get you to take a look at www.brendasfire.com/amej/darvan.html
    > andoffer suggestions before I jump off into something I can't crawl out of.


    1. *Always* specify units - 800 m, 400 m, etc.

    2. The abbreviation for centimetre is cm, not CM. Incidentally, cm is
    not an official unit of measure, but metre (m) is - but that is way
    to picky for your application.

    If you intend the results to be sent to some official sports body,
    consider making all measurements metres (at least seek the opinion
    of a few reputable organisations for their opinion).

    3. If there is a choice of only two values (yes/no, on/off), use a
    checkbox:

    <label for="hurdles400">400&nbsp;m&nbsp;Hurdles:&nbsp<input
    type="checkbox" name="hurdles400" id="hurdles400"></label>

    4. If your validation fails, you should return false to stop the form
    from submitting:

    <form ... onsubmit="return validForm(this);">

    and in the function validForm():

    return intHasError;

    In some browsers, onsubmit returns the value of the function that it
    called (i.e. relays validForm's 'false' to the form), but some
    don't. Even if the function returns "false", the actual onsubmit
    has been successful and so it can be argued that it should return
    success (or true) even if the function returned false - unless it is
    programmed explicitly to forward the returned value.

    This makes sense, so you can test if the function itself worked or
    not. That is, onsubmit succeeded but returned false. But it isn't
    how the majority of browsers actually work (as far as I know).

    5. Don't use language in your script tag, just use type:

    <script type="text/javascript">

    6. In your script, you have 11 document.write calls. Using an array
    and join() is much more efficient:

    var docContent = [
    '<html><head><title>Darvans Track Program</title>',
    '<style type="text/css">',
    '.letterhead {text-align: center;',
    ' text-decoration: "bold";}',
    '</style>',
    '</head><body>',
    '<p class="letterhead">James Darvan</p>',
    '<p class="letterhead">we live somewhere</p>',
    '<p class="letterhead">in some city</p><br />',
    '<p>Date: frmThis.completiondate.value</p><br>',
    '<p>in some city</p><br />',
    '<p onclick="self.close()" style="color: blue;',
    ' text-decoration: underline;">Close</p>',
    '</body></html>'
    ];

    generator.document.write(docContent.join(''));
    generator.document.close()

    7. Don't use <a href="javascript:... > Try this:

    <p onclick="self.close()" style="color: blue;
    text-decoration: underline;">Close</p>

    8. There are also much more efficient ways of going through your form
    elements to validate the content, but I'll leave that for later.


    My $0.02 worth. :p


    --
    Rob
     
    RobG, Jan 13, 2005
    #2
    1. Advertising

  3. Al Jones

    Al Jones Guest

    On Thu, 13 Jan 2005 05:13:32 GMT, RobG <> wrote:

    > Al Jones wrote:
    >> Could I get you to take a look at www.brendasfire.com/amej/darvan.html
    >> andoffer suggestions before I jump off into something I can't crawl out
    >> of.


    > <<snipped>>
    > 2. The abbreviation for centimetre is cm, not CM. Incidentally, cm is
    > not an official unit of measure, but metre (m) is - but that is way
    > to picky for your application.

    Sometimes I like picky, this particular one hit my funny bone -
    measurements are to be printed in meters as well as feet and tenths of
    feet <huh??>

    <<snipped>>
    > 6. In your script, you have 11 document.write calls. Using an array
    > and join() is much more efficient:
    >
    > var docContent = [

    ah, I like that - should save me some major typing when I get the
    mathematics in place.

    > My $0.02 worth. :p

    also worth at least a cuppa at some point in time. appreciate it much //al
     
    Al Jones, Jan 13, 2005
    #3
  4. Al Jones

    Al Jones Guest

    On Thu, 13 Jan 2005 05:13:32 GMT, RobG <> wrote:

    > '<p class="letterhead">we live somewhere</p>',
    > '<p class="letterhead">in some city</p><br />',
    > '<p>Date: frmThis.completiondate.value</p><br>', <--**
    > '<p>in some city</p><br />',
    > '<p onclick="self.close()" style="color: blue;',
    > ' text-decoration: underline;">Close</p>',
    > '</body></html>'
    > ];
    >

    Well, that was stupid, I just thought I had some idea of what I was
    doing. Knowing it wouldn't work I put it in the code as a placeholder.
    I've spent the last two hours on google groups to no avail - on the line
    marked with the *'s how does one insert text and a form variable??
     
    Al Jones, Jan 13, 2005
    #4
  5. Al Jones

    Al Jones Guest

    On Thu, 13 Jan 2005 13:00:37 -0600, Al Jones <>
    wrote:

    > On Thu, 13 Jan 2005 05:13:32 GMT, RobG <> wrote:
    >
    >> '<p class="letterhead">we live somewhere</p>',
    >> '<p class="letterhead">in some city</p><br />',
    >> '<p>Date: frmThis.completiondate.value</p><br>', <--**
    >> '<p>in some city</p><br />',
    >> '<p onclick="self.close()" style="color: blue;',
    >> ' text-decoration: underline;">Close</p>',
    >> '</body></html>'
    >> ];
    >>

    > Well, that was stupid, I just thought I had some idea of what I was
    > doing. Knowing it wouldn't work I put it in the code as a placeholder.
    > I've spent the last two hours on google groups to no avail - on the line
    > marked with the *'s how does one insert text and a form variable??


    I *said* it was stupid ... started cracking ebooks and one of the first
    examples I see is how to do that ...

    I do *not* do frustration well! Yes, I talk to myself when I'm working,
    too!
     
    Al Jones, Jan 13, 2005
    #5
  6. Al Jones

    Toby Inkster Guest

    RobG wrote:

    > 6. In your script, you have 11 document.write calls. Using an array
    > and join() is much more efficient:
    >
    > var docContent = [
    > '<html><head><title>Darvans Track Program</title>',
    > '<style type="text/css">',
    > '.letterhead {text-align: center;',
    > ' text-decoration: "bold";}',
    > '</style>',
    > '</head><body>',
    > '<p class="letterhead">James Darvan</p>',
    > '<p class="letterhead">we live somewhere</p>',
    > '<p class="letterhead">in some city</p><br />',
    > '<p>Date: frmThis.completiondate.value</p><br>',
    > '<p>in some city</p><br />',
    > '<p onclick="self.close()" style="color: blue;',
    > ' text-decoration: underline;">Close</p>',
    > '</body></html>'
    > ];


    Of course, in this particular case, that would be invalid HTML.

    Ignoring the fact that HTML and XHTML syntax are mixed higglty-pigglty,
    and ignoring the fact that it's missing a DOCTYPE, you have lots of '</'
    strings, which are illegal in a <script>...</script> block.

    If the Javascript was in an external file, then you'd only have to worry
    about the mixed HTML/XHTML syntax and the lack of DOCTYPE.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Jan 14, 2005
    #6
  7. Al Jones

    Al Jones Guest

    On Fri, 14 Jan 2005 08:04:48 +0000, Toby Inkster
    <> wrote:

    > RobG wrote:
    >
    >> 6. In your script, you have 11 document.write calls. Using an array
    >> and join() is much more efficient:
    >>
    >> var docContent = [
    >> '<html><head><title>Darvans Track Program</title>',
    >> '<style type="text/css">',
    >> '.letterhead {text-align: center;',
    >> ' text-decoration: "bold";}',
    >> '</style>',
    >> '</head><body>',
    >> '<p class="letterhead">James Darvan</p>',
    >> '<p class="letterhead">we live somewhere</p>',
    >> '<p class="letterhead">in some city</p><br />',
    >> '<p>Date: frmThis.completiondate.value</p><br>',
    >> '<p>in some city</p><br />',
    >> '<p onclick="self.close()" style="color: blue;',
    >> ' text-decoration: underline;">Close</p>',
    >> '</body></html>'
    >> ];

    >
    > Of course, in this particular case, that would be invalid HTML.
    >
    > Ignoring the fact that HTML and XHTML syntax are mixed higglty-pigglty,
    > and ignoring the fact that it's missing a DOCTYPE, you have lots of '</'
    > strings, which are illegal in a <script>...</script> block.
    >
    > If the Javascript was in an external file, then you'd only have to worry
    > about the mixed HTML/XHTML syntax and the lack of DOCTYPE.
    >

    I've been validating this all alone, helps to catch my stupidy errors, but
    you're quite right, when I started to create this very dynamic piece of
    code the validator threwup all over it.

    The two projects that I have going are an attempt to get away from the
    Dreamweaver wysiwyg that I've been doing some support stuff in.

    Would you mind getting more specific on how it *should* <??> be done in
    your opinion. (and that was *not* sarcasm)

    Thanks //al
     
    Al Jones, Jan 14, 2005
    #7
  8. Al Jones

    Toby Inkster Guest

    Al Jones wrote:

    > Would you mind getting more specific on how it *should* <??> be done in
    > your opinion.


    Here are two ways:

    document.write('<\/p>');

    or

    document.write('<' + '/p>');

    But the best way is to simply move the Javascript into an external file.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Jan 15, 2005
    #8
  9. Toby Inkster wrote:
    <snip>
    > document.write('<\/p>');
    >
    > or
    >
    > document.write('<' + '/p>');

    T
    he former being more efficient as it completely avoids the string
    concatenation that is relatively slow and heavyweight in some common
    browsers (such as IE). (less bytes to download as well).

    > But the best way is to simply move the Javascript into
    > an external file.


    Absolutely, and allows the users of script incapable/disabled browsers
    to avoid downloading scripts that will never be executed.

    Richard.
     
    Richard Cornford, Jan 15, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Claude
    Replies:
    0
    Views:
    351
    Claude
    Mar 7, 2004
  2. Wayne...
    Replies:
    15
    Views:
    772
    Toby Inkster
    Jul 23, 2004
  3. Andy Dingley
    Replies:
    45
    Views:
    1,654
    Andy Mabbett
    Jun 11, 2006
  4. RC
    Replies:
    2
    Views:
    445
    Chase Preuninger
    Jan 8, 2008
  5. jacob navia
    Replies:
    5
    Views:
    548
    spinoza1111
    May 30, 2010
Loading...

Share This Page