Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   Is this too far off topic?? (http://www.velocityreviews.com/forums/t160582-is-this-too-far-off-topic.html)

Al Jones 01-13-2005 04:04 AM

Is this too far off topic??
 
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.

RobG 01-13-2005 05:13 AM

Re: Is this too far off topic??
 
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

Al Jones 01-13-2005 05:24 AM

Re: Is this too far off topic??
 
On Thu, 13 Jan 2005 05:13:32 GMT, RobG <rgqld@iinet.net.auau> 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 01-13-2005 07:00 PM

Re: Is this too far off topic??
 
On Thu, 13 Jan 2005 05:13:32 GMT, RobG <rgqld@iinet.net.auau> 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 01-13-2005 08:29 PM

Re: Is this too far off topic??
 
On Thu, 13 Jan 2005 13:00:37 -0600, Al Jones <alfredmjones@shotmail.com>
wrote:

> On Thu, 13 Jan 2005 05:13:32 GMT, RobG <rgqld@iinet.net.auau> 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!

Toby Inkster 01-14-2005 08:04 AM

Re: Is this too far off topic??
 
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


Al Jones 01-14-2005 11:21 PM

Re: Is this too far off topic??
 
On Fri, 14 Jan 2005 08:04:48 +0000, Toby Inkster
<usenet200501@tobyinkster.co.uk> 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

Toby Inkster 01-15-2005 09:29 AM

Re: Is this too far off topic??
 
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


Richard Cornford 01-15-2005 01:26 PM

Re: Is this too far off topic??
 
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.




All times are GMT. The time now is 04:26 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.