/    Sign up×
Community /Pin to ProfileBookmark

Javascript calculations suppressed – advice?

First, here’s the structure of the source.

[code]<head>
**HEAD HTML-A**
<script> **JSCRIPT-1** </script>
</head>
<body>
<script> **JSCRIPT-2** </script>
**FORM HTML-B**
</body>[/code]

Now the concept, as-is.

This is a login page, and it loads in a low-bandwidth setup. There is a checkbox (in “B”) that, when checked the person loggin in is selecting to log in with an unrestricted bandwidth, at a cost. Thus, checking the box modifies some visible price value (initially at some value) on the page.

When the page loads in a low-bandwidth environment, the HTML-B takes some time to load. The form inputs themselves appear immediately and the pretty stuff like .gif files and such take some time to download after that. So far so good. That’s not a problem in and of itself.

However, when the checkbox input “upgrade bandwidth” is checked, a numeric value on the form (in dollars) is changed via scripts in JSCRIPT-2. Now for some reason, in a low bandwidth environment, the calculations in JSCRIPT-2 seem to start but are held back while the page finishes loading the .gif files and such. As a result, the price value become $0 (no matter the initial value) until the page loads. After the page is fully loaded, the calculations finish.

Thus, while the page is chugging along, a user can check the box and hit “submit” before the page finishes loading, resulting is submitting the form with an uncalculated ($0??) dollar value.

….

So here’s my question:

Is there a way to ensure that the JSCRIPT-2 calculations have top priority, even over the page itself being loaded to completion? Thanks.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@LostInDaJungleJun 05.2006 — if you're using a "onSubmit" form action you might get this. More code, more help.
×

Success!

Help @malignor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...