Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bust my code!

1 view
Skip to first unread message

jha...@gmail.com

unread,
Sep 23, 2008, 2:57:36 PM9/23/08
to
I created this order form for my company that will only allow
multiples of 10 copies to be ordered for certain documents. However, I
have had two customers day that when entering their order, they cannot
get the function to work correctly. Please let me know if you can find
a problem with my code and tell me what I'm doing wrong! I've tested
on IE 6.0 and Mozilla 3.0. Please, bust my code!

Ivan Marsh

unread,
Sep 23, 2008, 2:59:18 PM9/23/08
to

I can find no problem what so ever with your code.

--
I told you this was going to happen.

Conrad Lender

unread,
Sep 23, 2008, 3:02:32 PM9/23/08
to
On 2008-09-23 20:57, jha...@gmail.com wrote:
> Please let me know if you can find a problem with
> my code and tell me what I'm doing wrong! I've tested
> on IE 6.0 and Mozilla 3.0. Please, bust my code!

I think I know what the problem is.

Hope that helped.


- Conrad

PS: Are the posts getting more and more bizarre in this group?

Message has been deleted

jha...@gmail.com

unread,
Sep 23, 2008, 3:06:48 PM9/23/08
to
I'm an airhead! Here's the page:

http://fipco.com/products/hard_copy_order.php

Conrad Lender

unread,
Sep 23, 2008, 3:20:39 PM9/23/08
to
On 2008-09-23 21:06, jha...@gmail.com wrote:
> I'm an airhead! Here's the page:
>
> http://fipco.com/products/hard_copy_order.php

The very first thing that happens when you start typing in one of the
quantity fields is a JavaScript error "numbersonly is not defined". You
must have noticed this error, since it occurs in FF3 too, and you tested
with this browser (assuming "Mozilla 3.0" refers to Firefox 3).

As for the rest, please enter your URL here and you'll see a host of
other problems with this page: http://validator.w3.org/


- Conrad

Thomas 'PointedEars' Lahn

unread,
Sep 23, 2008, 4:12:18 PM9/23/08
to
Conrad Lender wrote:
> PS: Are the posts getting more and more bizarre in this group?

You ain't seen nothin' yet ;-)


Regards,

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>

dhtml

unread,
Sep 23, 2008, 9:15:32 PM9/23/08
to
Conrad Lender wrote:
> On 2008-09-23 20:57, jha...@gmail.com wrote:
>> Please let me know if you can find a problem with
>> my code and tell me what I'm doing wrong! I've tested
>> on IE 6.0 and Mozilla 3.0. Please, bust my code!
>
> I think I know what the problem is.
>
> Hope that helped.
>

LOL

dhtml

unread,
Sep 23, 2008, 9:35:08 PM9/23/08
to
function rounder(aObj) {
if (aObj.value == "") {
return;
}
aObj.value = Math.ceil(parseInt(aObj.value) / 10) * 10;
}


Maybe:

function shiftValueUpTo10(input) {
var val = parseInt(input.value, 10);

// Fix bug for NaN, 0, et c.
if(!val) {
input.value = "";
} else {
input.value = Math.ceil(val/10) * 10;
}
}

Use parseInt with a radix to avoid mishaps with base 8 (octal).

For example, the user might have entered: "08"

That results in the base 8 being used and the result of:
parseInt("08")

- is 0.


Garrett

RobG

unread,
Sep 23, 2008, 11:09:46 PM9/23/08
to
On Sep 24, 11:35 am, dhtml <dhtmlkitc...@gmail.com> wrote:

> jhai...@gmail.com wrote:
> > I'm an airhead! Here's the page:
>
> >http://fipco.com/products/hard_copy_order.php
>
> > On Sep 23, 1:57 pm, jhai...@gmail.com wrote:
> >> I created this order form for my company that will only allow
> >> multiples of 10 copies to be ordered for certain documents. However, I
> >> have had two customers day that when entering their order, they cannot
> >> get the function to work correctly. Please let me know if you can find
> >> a problem with my code and tell me what I'm doing wrong! I've tested
> >> on IE 6.0 and Mozilla 3.0. Please, bust my code!
>
> function rounder(aObj) {
>    if (aObj.value == "") {
>      return;
>    }
>    aObj.value = Math.ceil(parseInt(aObj.value) / 10) * 10;
>
> }
>
> Maybe:
>
> function shiftValueUpTo10(input) {
>    var val = parseInt(input.value, 10);

It seems sensible to validate what the user has entered before using
it, that way parseInt can be ditched entirely, e.g.:

function isInteger(n) {
var re = /^\d+$/;
return re.test(n);
}

function shiftValueUpTo10(input) {
var val = input.value;
input.value = isInteger(val)? ((val/10|0) +1 )*10 : '';
}


--
Rob

dhtml

unread,
Sep 23, 2008, 11:19:47 PM9/23/08
to

Hmm. If value is "0", then value becomes "10".

The user might see this as an unscrupulous way to add unwanted items to
his cart.

>
> --
> Rob

RobG

unread,
Sep 24, 2008, 12:12:29 AM9/24/08
to

Or useful assistance provided by his or her friendly
(over)supplier. :-)


--
Rob

Laser Lips

unread,
Sep 24, 2008, 5:08:35 AM9/24/08
to

How do these people get Jobs?

Dr J R Stockton

unread,
Sep 24, 2008, 11:09:00 AM9/24/08
to
On Sep 24, 2:35 am, dhtml <dhtmlkitc...@gmail.com> wrote:

> Use parseInt with a radix to avoid mishaps with base 8 (octal).

IMHO. parseInt and parseFloat should ONLY be used when unary + (or
unary -) would not serve.

--
(c) John Stockton, near London, UK. Posting with Google.
Mail: J.R.""""""""@physics.org or (better) via Home Page at
Web: <URL:http://www.merlyn.demon.co.uk/>
FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|

0 new messages