Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Is this too far off topic??

Reply
Thread Tools

Is this too far off topic??

 
 
Al Jones
Guest
Posts: n/a
 
      01-13-2005
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.
 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      01-13-2005
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<inp ut
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
 
Reply With Quote
 
 
 
 
Al Jones
Guest
Posts: n/a
 
      01-13-2005
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
 
Reply With Quote
 
Al Jones
Guest
Posts: n/a
 
      01-13-2005
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??
 
Reply With Quote
 
Al Jones
Guest
Posts: n/a
 
      01-13-2005
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!
 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      01-14-2005
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

 
Reply With Quote
 
Al Jones
Guest
Posts: n/a
 
      01-14-2005
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
 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      01-15-2005
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

 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      01-15-2005
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WiMAX in 2010: Too little, too late? How fast, how far, how much? Obaid MCSA 0 10-19-2009 12:12 PM
WiMAX in 2010: Too little, too late? How fast, how far, how much? Obaid MCAD 0 10-19-2009 12:12 PM
ToolTipText pop up far far away from mouse pointer RC Java 2 01-08-2008 12:54 AM
Taking table-less CSS design far too far Andy Dingley HTML 45 06-11-2006 07:14 PM
Wireless distance far too short M Skabialka Wireless Networking 3 01-14-2005 07:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57