Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22377 > unrolled thread
| Started by | Jim Rojas <jrojas@tech-man.com> |
|---|---|
| First post | 2013-12-23 20:17 -0500 |
| Last post | 2013-12-27 23:25 +0100 |
| Articles | 20 on this page of 22 — 6 participants |
Back to article view | Back to comp.lang.javascript
Javascript Help Needed Jim Rojas <jrojas@tech-man.com> - 2013-12-23 20:17 -0500
Re: Javascript Help Needed "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-12-24 09:17 +0100
Re: Javascript Help Needed Jim Rojas <jrojas@tech-man.com> - 2013-12-24 10:01 -0500
Re: Javascript Help Needed Jim Rojas <jrojas@tech-man.com> - 2013-12-24 10:02 -0500
Re: Javascript Help Needed "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-12-24 18:11 +0100
Re: Javascript Help Needed Jim Rojas <jrojas@tech-man.com> - 2013-12-24 12:24 -0500
Re: Javascript Help Needed "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-12-24 19:03 +0100
Re: Javascript Help Needed Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-24 19:18 +0000
Re: Javascript Help Needed Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-12-25 23:06 +0000
Re: Javascript Help Needed Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-24 19:52 +0000
Re: Javascript Help Needed Jim Rojas <jrojas@tech-man.com> - 2013-12-24 15:02 -0500
Re: Javascript Help Needed Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-24 22:07 +0100
Re: Javascript Help Needed Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-25 02:16 +0000
Re: Javascript Help Needed Jim Rojas <jrojas@tech-man.com> - 2013-12-24 21:48 -0500
Re: Javascript Help Needed Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-12-25 23:05 +0000
Re: Javascript Help Needed Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-24 22:09 +0100
Re: Javascript Help Needed Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-25 01:51 +0000
Re: Javascript Help Needed Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-26 07:38 +0100
Re: Javascript Help Needed Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-26 10:42 +0100
Re: Javascript Help Needed Jim Rojas <jrojas@tech-man.com> - 2013-12-26 13:14 -0500
Re: Javascript Help Needed Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-27 22:49 +0100
Re: Javascript Help Needed Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-27 23:25 +0100
Page 1 of 2 [1] 2 Next page →
| From | Jim Rojas <jrojas@tech-man.com> |
|---|---|
| Date | 2013-12-23 20:17 -0500 |
| Subject | Javascript Help Needed |
| Message-ID | <6h5uu.25363$gh2.7307@fx24.iad> |
Hi. I have a javascript that needs to be modified to provide some basic shipping calculations I need for my website. The script basically takes an array, and then displays it on a webpage. At this point, there is only one table array. I need it to display 3 at the same time. I understand how to manipulate the data, it is the javascript itself I am having trouble with. I also want to be able to break up the code so the array tables are in an include file for easy future modifications. Thank you Jim Rojas --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
[toc] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-12-24 09:17 +0100 |
| Message-ID | <XnsA2A05E790CBE2eejj99@194.109.133.133> |
| In reply to | #22377 |
Jim Rojas <jrojas@tech-man.com> wrote on 24 dec 2013 in
comp.lang.javascript:
> Hi. I have a javascript that needs to be modified
This NG is not about scripting Java,
so perhaps you mean "a Javascript script"?
> to provide some basic
> shipping calculations I need for my website.
> The script basically takes an array, and then displays it on a webpage.
> At this point, there is only one table array. I need it to display 3 at
> the same time.
As you perhaps not know, we discuss Javascript scripting here,
we don't provide scripts on demand [well, you could meet some overzealous
bloke here in a particular xmas mood], so perhaps you can give a short
example of what you have done sofar, excluding any scripting not part of
your problem, and specificly show us why you cannot make a function
applicable to three seperate tables getting data from three seperate arrays:
function fillTable( table-id, table-array ) { ... };
> I understand how to manipulate the data, it is the javascript itself I
> am having trouble with.
I don't see how those two are seperable, Jim.
Surely the thing you do is manipulating the data with Javascript?
> I also want to be able to break up the code so the array tables are in
> an include file for easy future modifications.
There is no need to break up the Javascript code for that,
you better copy your code into your next endavour,
as otherwize you would have to test all your older pages for errors
following your "improvements".
> ... want to be able ...
But really, is this just a statement or a Q?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Jim Rojas <jrojas@tech-man.com> |
|---|---|
| Date | 2013-12-24 10:01 -0500 |
| Message-ID | <Pkhuu.63688$ad.14790@fx04.iad> |
| In reply to | #22378 |
Evertjan. wrote:
> Jim Rojas <jrojas@tech-man.com> wrote on 24 dec 2013 in
> comp.lang.javascript:
>
>> Hi. I have a javascript that needs to be modified
>
> This NG is not about scripting Java,
> so perhaps you mean "a Javascript script"?
>
>> to provide some basic
>> shipping calculations I need for my website.
>
>> The script basically takes an array, and then displays it on a webpage.
>> At this point, there is only one table array. I need it to display 3 at
>> the same time.
>
> As you perhaps not know, we discuss Javascript scripting here,
> we don't provide scripts on demand [well, you could meet some overzealous
> bloke here in a particular xmas mood], so perhaps you can give a short
> example of what you have done sofar, excluding any scripting not part of
> your problem, and specificly show us why you cannot make a function
> applicable to three seperate tables getting data from three seperate arrays:
>
> function fillTable( table-id, table-array ) { ... };
>
>
>> I understand how to manipulate the data, it is the javascript itself I
>> am having trouble with.
>
> I don't see how those two are seperable, Jim.
>
> Surely the thing you do is manipulating the data with Javascript?
>
>> I also want to be able to break up the code so the array tables are in
>> an include file for easy future modifications.
>
> There is no need to break up the Javascript code for that,
> you better copy your code into your next endavour,
> as otherwize you would have to test all your older pages for errors
> following your "improvements".
>
>> ... want to be able ...
>
> But really, is this just a statement or a Q?
>
The code right now works fine. It calculates just one shipping rate. I
want to be able to calculate 3 rates at the same time.
USPS postage rate for FCPIS, PMI & PMEI. I have the script working on a
test page. You will see the output display the way I need it to. I just
don't understand how to add the other 2 tables to the script.
http://www.inshipsoultions.com/uspstest.html
The complete sourcecode is in the html.
Thank you
Jim Rojas
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
[toc] | [prev] | [next] | [standalone]
| From | Jim Rojas <jrojas@tech-man.com> |
|---|---|
| Date | 2013-12-24 10:02 -0500 |
| Message-ID | <Cmhuu.63689$ad.34524@fx04.iad> |
| In reply to | #22380 |
Jim Rojas wrote: > http://www.inshipsoultions.com/uspstest.html Sorry http://www.inshipsolutions.com/uspstest.html Jim Rojas --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-12-24 18:11 +0100 |
| Message-ID | <XnsA2A0B90F3892Beejj99@194.109.133.133> |
| In reply to | #22380 |
Jim Rojas <jrojas@tech-man.com> wrote on 24 dec 2013 in
comp.lang.javascript:
> Evertjan. wrote:
>> Jim Rojas <jrojas@tech-man.com> wrote on 24 dec 2013 in
>> comp.lang.javascript:
>>
>>> Hi. I have a javascript that needs to be modified
>>
>> This NG is not about scripting Java,
>> so perhaps you mean "a Javascript script"?
Answer?
>>> to provide some basic
>>> shipping calculations I need for my website.
>>
>>> The script basically takes an array, and then displays it on a
>>> webpage. At this point, there is only one table array. I need it to
>>> display 3 at the same time.
>>
>> As you perhaps not know, we discuss Javascript scripting here,
>> we don't provide scripts on demand [well, you could meet some
>> overzealous bloke here in a particular xmas mood], so perhaps you can
>> give a short example of what you have done sofar, excluding any
>> scripting not part of your problem, and specificly show us why you
>> cannot make a function applicable to three seperate tables getting data
>> from three seperate arrays:
>>
>> function fillTable( table-id, table-array ) { ... };
>>
>>
>>> I understand how to manipulate the data, it is the javascript itself I
>>> am having trouble with.
>>
>> I don't see how those two are seperable, Jim.
>> Surely the thing you do is manipulating the data with Javascript?
Could you respond to this, Jim, this surely is about data-manipulation?
>>
>>> I also want to be able to break up the code so the array tables are in
>>> an include file for easy future modifications.
>> There is no need to break up the Javascript code for that,
>> you better copy your code into your next endavour,
>> as otherwize you would have to test all your older pages for errors
>> following your "improvements".
>>
>>> ... want to be able ...
>>
>> But really, is this just a statement or a Q?
>>
>
> The code right now works fine. It calculates just one shipping rate. I
> want to be able to calculate 3 rates at the same time.
Supposing this is a question to us, that would be possible by just writing a
script that accomodates that. [Well not exactly "at the same time", a as
javascript engines in browsers are not multithreaded.]
I suppose you mean you want YOUR CODE to be able to calculate that?
So you should be able to write the code for that.
> USPS postage rate for FCPIS, PMI & PMEI. I have the script working on a
> test page. You will see the output display the way I need it to. I just
> don't understand how to add the other 2 tables to the script.
>
> http://www.inshipsoultions.com/uspstest.html
You added:
~ Sorry
~ http://www.inshipsolutions.com/uspstest.html
> The complete sourcecode is in the html.
That's why I asked tou to write a SHORT simple example, I don't want to go
through this large amount of code, neither will I write functional code for
you.
I can only emhasize you could write a function that is fed by the parameters
you give, and returns results depending on those parameters in the requested
html-table as per your wish:
function fillTable( table-id, data-array ) {
[code you should write here];
};
and then do:
fillTable( table-id-1, data-array-1 );
fillTable( table-id-2, data-array-2 );
fillTable( table-id-3, data-array-3 );
Could you start with that?
In the testing/debugging fase that must follow your scripting strive,
is would be best for you to reduce the enormous arrays to arrays of one or
two lines, perhaps even in one or more seperate script files, [or as
suggested by others in a csv file.] So after testing that those arrays are
coherent in code, you could concentrate at the functional code at hand.
=================== test.html =============================
<script src='my-arrays.js'></script>
<script>
function fillTable( a-table-id, a-data-array ) {
[code you should write here];
};
function filltables(){
fillTable( table-id-1, data-array-1 );
fillTable( table-id-2, data-array-2 );
fillTable( table-id-3, data-array-3 );
};
body.onload = filltables;
</script>
<table id='table-id-1'> ... </table>
<table id='table-id-2'> ... </table>
<table id='table-id-3'> ... </table>
===================================================
> --
> This email is free from viruses and malware because avast! Antivirus
> protection is active. http://www.avast.com
What nonsense, this posting of yours is NOT AN EMAIL AT ALL!
As this NG is text-only, there is no reason to expect a virus to run anyway.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Jim Rojas <jrojas@tech-man.com> |
|---|---|
| Date | 2013-12-24 12:24 -0500 |
| Message-ID | <arjuu.57225$Qi4.22852@fx11.iad> |
| In reply to | #22382 |
Evertjan. wrote:
> Jim Rojas <jrojas@tech-man.com> wrote on 24 dec 2013 in
> comp.lang.javascript:
>
>> Evertjan. wrote:
>>> Jim Rojas <jrojas@tech-man.com> wrote on 24 dec 2013 in
>>> comp.lang.javascript:
>>>
>>>> Hi. I have a javascript that needs to be modified
>>>
>>> This NG is not about scripting Java,
>>> so perhaps you mean "a Javascript script"?
>
> Answer?
>
>>>> to provide some basic
>>>> shipping calculations I need for my website.
>>>
>>>> The script basically takes an array, and then displays it on a
>>>> webpage. At this point, there is only one table array. I need it to
>>>> display 3 at the same time.
>>>
>>> As you perhaps not know, we discuss Javascript scripting here,
>>> we don't provide scripts on demand [well, you could meet some
>>> overzealous bloke here in a particular xmas mood], so perhaps you can
>>> give a short example of what you have done sofar, excluding any
>>> scripting not part of your problem, and specificly show us why you
>>> cannot make a function applicable to three seperate tables getting data
>>> from three seperate arrays:
>>>
>>> function fillTable( table-id, table-array ) { ... };
>>>
>>>
>>>> I understand how to manipulate the data, it is the javascript itself I
>>>> am having trouble with.
>>>
>>> I don't see how those two are seperable, Jim.
>>> Surely the thing you do is manipulating the data with Javascript?
>
> Could you respond to this, Jim, this surely is about data-manipulation?
>
>>>
>>>> I also want to be able to break up the code so the array tables are in
>>>> an include file for easy future modifications.
>
>>> There is no need to break up the Javascript code for that,
>>> you better copy your code into your next endavour,
>>> as otherwize you would have to test all your older pages for errors
>>> following your "improvements".
>>>
>>>> ... want to be able ...
>>>
>>> But really, is this just a statement or a Q?
>>>
>>
>> The code right now works fine. It calculates just one shipping rate. I
>> want to be able to calculate 3 rates at the same time.
>
> Supposing this is a question to us, that would be possible by just writing a
> script that accomodates that. [Well not exactly "at the same time", a as
> javascript engines in browsers are not multithreaded.]
>
> I suppose you mean you want YOUR CODE to be able to calculate that?
> So you should be able to write the code for that.
>
>> USPS postage rate for FCPIS, PMI & PMEI. I have the script working on a
>> test page. You will see the output display the way I need it to. I just
>> don't understand how to add the other 2 tables to the script.
>>
>> http://www.inshipsoultions.com/uspstest.html
>
> You added:
> ~ Sorry
> ~ http://www.inshipsolutions.com/uspstest.html
>
>> The complete sourcecode is in the html.
>
> That's why I asked tou to write a SHORT simple example, I don't want to go
> through this large amount of code, neither will I write functional code for
> you.
>
> I can only emhasize you could write a function that is fed by the parameters
> you give, and returns results depending on those parameters in the requested
> html-table as per your wish:
>
> function fillTable( table-id, data-array ) {
> [code you should write here];
> };
>
> and then do:
>
> fillTable( table-id-1, data-array-1 );
> fillTable( table-id-2, data-array-2 );
> fillTable( table-id-3, data-array-3 );
>
> Could you start with that?
>
> In the testing/debugging fase that must follow your scripting strive,
> is would be best for you to reduce the enormous arrays to arrays of one or
> two lines, perhaps even in one or more seperate script files, [or as
> suggested by others in a csv file.] So after testing that those arrays are
> coherent in code, you could concentrate at the functional code at hand.
>
> =================== test.html =============================
>
> <script src='my-arrays.js'></script>
> <script>
>
> function fillTable( a-table-id, a-data-array ) {
> [code you should write here];
> };
>
> function filltables(){
> fillTable( table-id-1, data-array-1 );
> fillTable( table-id-2, data-array-2 );
> fillTable( table-id-3, data-array-3 );
> };
>
> body.onload = filltables;
>
> </script>
> <table id='table-id-1'> ... </table>
> <table id='table-id-2'> ... </table>
> <table id='table-id-3'> ... </table>
>
> ===================================================
>
>> --
>> This email is free from viruses and malware because avast! Antivirus
>> protection is active. http://www.avast.com
>
> What nonsense, this posting of yours is NOT AN EMAIL AT ALL!
> As this NG is text-only, there is no reason to expect a virus to run anyway.
>
I do not know how to write script. But your explanation will give me
something I can work with. I understand html, so I am not totally lost here.
I will let you know my progress.
Thank you
Jim Rojas
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-12-24 19:03 +0100 |
| Message-ID | <XnsA2A0C1CF14D5eejj99@194.109.133.133> |
| In reply to | #22383 |
Jim Rojas <jrojas@tech-man.com> wrote on 24 dec 2013 in comp.lang.javascript: > I do not know how to write script. This is about javascript, so perhaps you should start with perusing one or two javascript tutorials? > I understand html, so I am not totally lost here. That will not help you, I presume. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-12-24 19:18 +0000 |
| Message-ID | <l9cmm1$do9$1@dont-email.me> |
| In reply to | #22383 |
On Tue, 24 Dec 2013 12:24:19 -0500, Jim Rojas wrote: > I understand html, so I am not totally lost here. I beg to differ. You close more tables than you open, you close more table cells than you open, and you have tables and table cells with no table rows. And that's just the stuff I fixed quickly. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> |
|---|---|
| Date | 2013-12-25 23:06 +0000 |
| Message-ID | <cT4RPsRpT2uSFwBT@invalid.uk.co.demon.merlyn.invalid> |
| In reply to | #22378 |
In comp.lang.javascript message <XnsA2A05E790CBE2eejj99@194.109.133.133>
, Tue, 24 Dec 2013 09:17:13, Evertjan. <exxjxw.hannivoort@inter.nl.net>
posted:
>
>As you perhaps not know, we discuss Javascript scripting here,
>we don't provide scripts on demand [well, you could meet some overzealous
>bloke here in a particular xmas mood], so perhaps you can give a short
>example of what you have done sofar, excluding any scripting not part of
^
>your problem, and specificly show us why you cannot make a function
^al
>applicable to three seperate tables getting data from three seperate arrays:
separate separate
>
>function fillTable( table-id, table-array ) { ... };
Why are you putting subtractions in the arguments?
--
(c) John Stockton, nr London, UK. Mail via homepage. Turnpike v6.05 MIME.
Web <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms and links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Mail no News.
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-12-24 19:52 +0000 |
| Message-ID | <l9colr$do9$2@dont-email.me> |
| In reply to | #22377 |
On Mon, 23 Dec 2013 20:17:54 -0500, Jim Rojas wrote: > Hi. I have a javascript that needs to be modified to provide some basic > shipping calculations I need for my website. > > The script basically takes an array, and then displays it on a webpage. > At this point, there is only one table array. I need it to display 3 at > the same time. > > I understand how to manipulate the data, it is the javascript itself I > am having trouble with. > > I also want to be able to break up the code so the array tables are in > an include file for easy future modifications. Your problem description is still unclear. Perhaps you could step back and describe what you're actually trying to do, rather than trying to express things in terms of tables and arrays that are fairly meaningless. For example: "I have code to calculate shipping rates for usps. I also want to calculate shipping rates for fedex, ups and deutche post." Firstly, think about how you want to get input and present calculation results. Build the html structure that you want to input data from and put the results into. Secondly, get the base data needed for your calculations. I imagine this will be in the form of a table for each shipping method. Thirdly, write functions for each shipping method that takes the input data (us zip code or country of destination, package weight, package dimensions) and then calculates and displays the shipping for that shipping method using the base data. Perhaps I misunderstood what you're trying to do. I suggest that you put all your code in a single script section in the head of the document, that you don't use the "language" attribute for the script section, but instead use the type attribute: type="text/javascript" Ignore any elf-like apparition that tries to tell you this is wrong, and instead search the web to find out why this is right. Later on you may wish to separate your js code and data, and possibly have some server side system that automatically generates new data files when you update some set of master shipping cost tables. You have unescaped ampersands in your countries option list, and your innerhtml code includes html closing tags which it is usually a good idea to split up, eg instead of: blah.innerHTML += "</B>"; use something like: blah.innerHTML += "<"+"/"+"B>"; to avoid any sequence of '<' + '/' + letter occurring inside the script tags, as these may confuse the rendering engine. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Jim Rojas <jrojas@tech-man.com> |
|---|---|
| Date | 2013-12-24 15:02 -0500 |
| Message-ID | <JLluu.70428$Rt7.49487@fx27.iad> |
| In reply to | #22387 |
Denis McMahon wrote: > On Mon, 23 Dec 2013 20:17:54 -0500, Jim Rojas wrote: > >> Hi. I have a javascript that needs to be modified to provide some basic >> shipping calculations I need for my website. >> >> The script basically takes an array, and then displays it on a webpage. >> At this point, there is only one table array. I need it to display 3 at >> the same time. >> >> I understand how to manipulate the data, it is the javascript itself I >> am having trouble with. >> >> I also want to be able to break up the code so the array tables are in >> an include file for easy future modifications. > > Your problem description is still unclear. Perhaps you could step back > and describe what you're actually trying to do, rather than trying to > express things in terms of tables and arrays that are fairly meaningless. > > For example: > > "I have code to calculate shipping rates for usps. I also want to > calculate shipping rates for fedex, ups and deutche post." > > Firstly, think about how you want to get input and present calculation > results. Build the html structure that you want to input data from and > put the results into. > > Secondly, get the base data needed for your calculations. I imagine this > will be in the form of a table for each shipping method. > > Thirdly, write functions for each shipping method that takes the input > data (us zip code or country of destination, package weight, package > dimensions) and then calculates and displays the shipping for that > shipping method using the base data. > > Perhaps I misunderstood what you're trying to do. > > I suggest that you put all your code in a single script section in the > head of the document, that you don't use the "language" attribute for the > script section, but instead use the type attribute: type="text/javascript" > > Ignore any elf-like apparition that tries to tell you this is wrong, and > instead search the web to find out why this is right. > > Later on you may wish to separate your js code and data, and possibly > have some server side system that automatically generates new data files > when you update some set of master shipping cost tables. > > You have unescaped ampersands in your countries option list, and your > innerhtml code includes html closing tags which it is usually a good idea > to split up, eg instead of: > > blah.innerHTML += "</B>"; > > use something like: > > blah.innerHTML += "<"+"/"+"B>"; > > to avoid any sequence of '<' + '/' + letter occurring inside the script > tags, as these may confuse the rendering engine. > I didn't write the script. I am not a programmer. I grabbed the code off a javascript resource page. What I am trying to do is this: When you enter a package weight, I would like it to display 3 different shipping prices at the same time. Rate 1 is FCPIS Rate 2 is PMI Rate 3 is PMEI The script is originally only setup to display only one rate. The other rate arrays do not exist yet. All I did was copy the same output code display, and changed the name for display purposes only. Jim Rojas --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2013-12-24 22:07 +0100 |
| Message-ID | <52b9f7ab$0$9502$9b4e6d93@newsspool1.arcor-online.net> |
| In reply to | #22388 |
Jim Rojas wrote: > I didn't write the script. I am not a programmer. I grabbed the code off > a javascript resource page. What I am trying to do is this: > > When you enter a package weight, I would like it to display 3 different > shipping prices at the same time. > > Rate 1 is FCPIS > Rate 2 is PMI > Rate 3 is PMEI > > The script is originally only setup to display only one rate. The other > rate arrays do not exist yet. > > All I did was copy the same output code display, and changed the name > for display purposes only. As Evertjan has already written, you shouldn't expect somebody in this newsgroup to write the code for you. I see two options: either you're willing to learn as much "javascript" (actually, that is better be called ECMAScript and DOM) as necessary to write the code yourself (this newsgroup is helpful when you have specific questions), or you hire somebody else to do it for you. :) -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-12-25 02:16 +0000 |
| Message-ID | <l9df6r$do9$4@dont-email.me> |
| In reply to | #22388 |
On Tue, 24 Dec 2013 15:02:47 -0500, Jim Rojas wrote: > Rate 1 is FCPIS Rate 2 is PMI Rate 3 is PMEI You are assuming that I understand your abbreviations. I don't. They mean nothing to me in the UK, nor I suspect to others outside of your postal / shipping environment. Try explaining things better so we understand what you're trying to do. > The script is originally only setup to display only one rate. The other > rate arrays do not exist yet. > All I did was copy the same output code display, and changed the name > for display purposes only. Try looking at this page: http://www.sined.co.uk/tmp/usps2.htm Note that I have separated the data array variables, the javascript and the html. I gave up with the original js and wrote my own from scratch, although it could probably benefit from some performance optimisations and being made a little more robust concerning the values it expects as input and in the data arrays. You don't need to separate the national and international calculation, you can detect from the selection of USA as country that you want a zip code. If the country is not USA, perform an international calculation, otherwise perform a zip based calculation. If USA is selected and no zip is supplied, show an error indication on the zip field. Question - are the other rates based on the same zip code and international shipping zones as the USPS rates? If not, you will need separate zone data as well as separate zone -> rate lookups for them. Ditto the maximum weights. Your international data appears to assign the same country code to Vanuata and Uzbekistan, but although the the country code to zone lookup places both entries for UZ in the same zone, they have different maximum weights. This will cause a problem as either the maximum weight for Vanuatu will always be chosen, or the maximum weight for Uzbekistan. My code should be extendable to handle your multiple shipping methods provided that you make relevant edits and provide suitable data arrays to it, and that the general format of the other data arrays is the same as that of the USPS arrays. Note that the only changes you should need to make, if you provide suitably defined arrays of data for FCPIS, PMI and PMEI is to change the array names in the relevant lines in the array variable called control at the head of the usos2_code.js file, and to include the data files for the other methods in the document head. At the moment the code just calculates all 4 values using the same data arrays, as defined by the entries in the array variable "control". -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Jim Rojas <jrojas@tech-man.com> |
|---|---|
| Date | 2013-12-24 21:48 -0500 |
| Message-ID | <7Iruu.42141$BO3.7458@fx06.iad> |
| In reply to | #22393 |
Denis McMahon wrote: > On Tue, 24 Dec 2013 15:02:47 -0500, Jim Rojas wrote: > >> Rate 1 is FCPIS Rate 2 is PMI Rate 3 is PMEI > > You are assuming that I understand your abbreviations. I don't. They mean > nothing to me in the UK, nor I suspect to others outside of your postal / > shipping environment. Try explaining things better so we understand what > you're trying to do. If a customer from Brazil wants to know what the cost is to send a 1 pound package from my location to his country, he then: 1. Selects his country. 2. Enters the package weight in US pounds or Kg. 3. The instant he enters the weight, 3 different shipping costs show up. FCPIS is First Class Mail (2-4 weeks delivery) PMI is Priority Mail (6-10 days delivery) PMEI is Express Mail (3-5 days delivery) So for example it would display: FCPIS: $18.00 PMI: $24.50 PMEI: $38.95 The code works fine as is. But it is for only one rate array. I just need it to include 2 additional arrays. So right now, the code displays the same rate for each service, because the other arrays do not exist, and my code is duplicated for each service to display the only available array data. Thank you Jim Rojas >> The script is originally only setup to display only one rate. The other >> rate arrays do not exist yet. > >> All I did was copy the same output code display, and changed the name >> for display purposes only. > > Try looking at this page: > > http://www.sined.co.uk/tmp/usps2.htm > > Note that I have separated the data array variables, the javascript and > the html. I gave up with the original js and wrote my own from scratch, > although it could probably benefit from some performance optimisations > and being made a little more robust concerning the values it expects as > input and in the data arrays. > > You don't need to separate the national and international calculation, > you can detect from the selection of USA as country that you want a zip > code. If the country is not USA, perform an international calculation, > otherwise perform a zip based calculation. If USA is selected and no zip > is supplied, show an error indication on the zip field. > > Question - are the other rates based on the same zip code and > international shipping zones as the USPS rates? If not, you will need > separate zone data as well as separate zone -> rate lookups for them. > > Ditto the maximum weights. > > Your international data appears to assign the same country code to Vanuata > and Uzbekistan, but although the the country code to zone lookup places > both entries for UZ in the same zone, they have different maximum > weights. This will cause a problem as either the maximum weight for > Vanuatu will always be chosen, or the maximum weight for Uzbekistan. > > My code should be extendable to handle your multiple shipping methods > provided that you make relevant edits and provide suitable data arrays to > it, and that the general format of the other data arrays is the same as > that of the USPS arrays. > > Note that the only changes you should need to make, if you provide > suitably defined arrays of data for FCPIS, PMI and PMEI is to change the > array names in the relevant lines in the array variable called control at > the head of the usos2_code.js file, and to include the data files for the > other methods in the document head. > > At the moment the code just calculates all 4 values using the same data > arrays, as defined by the entries in the array variable "control". > --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
[toc] | [prev] | [next] | [standalone]
| From | Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> |
|---|---|
| Date | 2013-12-25 23:05 +0000 |
| Message-ID | <KTRUf2QNT2uSFwCt@invalid.uk.co.demon.merlyn.invalid> |
| In reply to | #22388 |
In comp.lang.javascript message <JLluu.70428$Rt7.49487@fx27.iad>, Tue, 24 Dec 2013 15:02:47, Jim Rojas <jrojas@tech-man.com> posted: > >I didn't write the script. I am not a programmer. I grabbed the code >off a javascript resource page. What I am trying to do is this: > Then the responsible professional thing for you to do is to advise your organisation that they need the services of a competent person rather than of an amateur bungler; and that they should either provide you with resources such that you can be properly taught how to program in general and also how to do so in JavaScript, or they should get a new employee who already has the necessary skills, or they should buy in scripting services from an assuredly reputable and competent supplier. Probably they should also dispose of your line manager. -- (c) John Stockton, nr London UK Reply address via Merlyn Home Page. news:comp.lang.javascript FAQ <http://www.jibbering.com/faq/index.html>. <http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources. <http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2013-12-24 22:09 +0100 |
| Message-ID | <52b9f810$0$9502$9b4e6d93@newsspool1.arcor-online.net> |
| In reply to | #22387 |
Denis McMahon wrote: > On Mon, 23 Dec 2013 20:17:54 -0500, Jim Rojas wrote: > > I suggest that you put all your code in a single script section in the > head of the document, that you don't use the "language" attribute for the > script section, but instead use the type attribute: type="text/javascript" > > Ignore any elf-like apparition that tries to tell you this is wrong, and > instead search the web to find out why this is right. It is absolutely fine to omit the type attribute, AFAIK. The only reason for using it, is to satisfy HTML 4.x[1] and XHTML 1.x; HTML5 is most likely (it is still a CR) going to drop this requirement[2]. > Later on you may wish to separate your js code and data, and possibly > have some server side system that automatically generates new data files > when you update some set of master shipping cost tables. > > You have unescaped ampersands in your countries option list, and your > innerhtml code includes html closing tags which it is usually a good idea > to split up, eg instead of: > > blah.innerHTML += "</B>"; > > use something like: > > blah.innerHTML += "<"+"/"+"B>"; > > to avoid any sequence of '<' + '/' + letter occurring inside the script > tags, as these may confuse the rendering engine. A simpler and more efficient solution to comply with HTML parsers (which might consider </ as introducing a closing tag) is: blah.innerHTML += "<\/B>" (Of course, one should preferably build up the value of the innerHTML property in advance.) [1] <http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1> [2] <http://www.w3.org/TR/html5/scripting-1.html#the-script-element> -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-12-25 01:51 +0000 |
| Message-ID | <l9ddng$do9$3@dont-email.me> |
| In reply to | #22390 |
On Tue, 24 Dec 2013 22:09:40 +0100, Christoph Michael Becker wrote: > Denis McMahon wrote: >> use something like: >> blah.innerHTML += "<"+"/"+"B>"; > A simpler and more efficient solution to comply with HTML parsers (which > might consider </ as introducing a closing tag) My personal preference is to build up the contents of the element using dom manipulation rather creating an innerHTML string, but I figured that might be too complex for the OP at this point. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-12-26 07:38 +0100 |
| Message-ID | <2691359.uFm2ZBFIHE@PointedEars.de> |
| In reply to | #22390 |
Christoph Michael Becker wrote: > Denis McMahon wrote: >> I suggest that you put all your code in a single script section in the >> head of the document, … thereby, *in general*, *slowing down* display and causing all kinds of other problems (IOW, bad advice) … >> that you don't use the "language" attribute for the >> script section, but instead use the type attribute: >> type="text/javascript" >> >> Ignore any elf-like apparition that tries to tell you this is wrong, and >> instead search the web to find out why this is right. Unsurprisingly, the Web tells why the former is, in general, wrong, and the latter is correct. <https://developers.google.com/speed/pagespeed/> > It is absolutely fine to omit the type attribute, AFAIK. The only > reason for using it, is to satisfy HTML 4.x[1] and XHTML 1.x; HTML5 is > most likely (it is still a CR) going to drop this requirement[2]. It depends on how compatible you want to be and what programming languages you are using in the document; see also the testcase referred in <http://stackoverflow.com/a/7227303/855543> (there will be a new URI for it). >> Later on you may wish to separate your js code and data, and possibly >> have some server side system that automatically generates new data files >> when you update some set of master shipping cost tables. >> >> You have unescaped ampersands in your countries option list, and your >> innerhtml code includes html closing tags which it is usually a good idea >> to split up, eg instead of: >> >> blah.innerHTML += "</B>"; >> >> use something like: >> >> blah.innerHTML += "<"+"/"+"B>"; >> >> to avoid any sequence of '<' + '/' + letter occurring inside the script >> tags, as these may confuse the rendering engine. > > A simpler and more efficient solution to comply with HTML parsers (which > might consider </ as introducing a closing tag) is: The proper terms are _end tag_ and End Tag Open (ETAGO) delimiter, respectively. ETAGO in script code is only necessary to be escaped if the code is in an HTML < 5 document. Nowadays the easiest and – for several reasons – recommended way to work around this is to include a script resource. In my experience, over time inline script code soon grows too much so that it is moved to an included script resource. There are other potential advantages of the latter, such as parallel loading and better editor support. This application, being small, and the script code limited to a single purpose, may be an exception. > blah.innerHTML += "<\/B>" > > (Of course, one should preferably build up the value of the innerHTML > property in advance.) A solution relying on “innerHTML” etc. alone is not accessible as it will not work if a script engine is not used. > [1] <http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1> > [2] <http://www.w3.org/TR/html5/scripting-1.html#the-script-element> Read more carefully before you cite: <http://www.w3.org/TR/2012/CR-html5-20121217/syntax.html#syntax> <http://www.w3.org/TR/2012/CR-html5-20121217/syntax.html#script-data-state> -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-12-26 10:42 +0100 |
| Message-ID | <1461294.7PQU9mpPJr@PointedEars.de> |
| In reply to | #22411 |
Thomas 'PointedEars' Lahn wrote: > Christoph Michael Becker wrote: >> Denis McMahon wrote: >>> use something like: >>> >>> blah.innerHTML += "<"+"/"+"B>"; >>> >>> to avoid any sequence of '<' + '/' + letter occurring inside the script >>> tags, as these may confuse the rendering engine. >> >> A simpler and more efficient solution to comply with HTML parsers (which >> might consider </ as introducing a closing tag) is: > > The proper terms are _end tag_ and End Tag Open (ETAGO) delimiter, > respectively. ETAGO in script code is only necessary to be escaped if the > code is in an HTML < 5 document. > > Nowadays the easiest and – for several reasons – recommended way to work > around this is to include a script resource. In my experience, over time > inline script code soon grows too much so that it is moved to an included > script resource. There are other potential advantages of the latter, such > as parallel loading and better editor support. This application, being > small, and the script code limited to a single purpose, may be an > exception. > >> blah.innerHTML += "<\/B>" >> > […] >> [1] <http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1> >> [2] <http://www.w3.org/TR/html5/scripting-1.html#the-script-element> > > Read more carefully before you cite: > > <http://www.w3.org/TR/2012/CR-html5-20121217/syntax.html#syntax> > <http://www.w3.org/TR/2012/CR-html5-20121217/syntax.html#script-data-state> Latest – as cited: <http://www.w3.org/TR/2013/CR-html5-20130806/syntax.html#syntax> <http://www.w3.org/TR/2013/CR-html5-20130806/syntax.html#script-data-state> -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Jim Rojas <jrojas@tech-man.com> |
|---|---|
| Date | 2013-12-26 13:14 -0500 |
| Message-ID | <Rl_uu.76099$2s6.74908@fx16.iad> |
| In reply to | #22413 |
Thomas 'PointedEars' Lahn wrote: > Thomas 'PointedEars' Lahn wrote: > >> Christoph Michael Becker wrote: >>> Denis McMahon wrote: >>>> use something like: >>>> >>>> blah.innerHTML += "<"+"/"+"B>"; >>>> >>>> to avoid any sequence of '<' + '/' + letter occurring inside the script >>>> tags, as these may confuse the rendering engine. >>> >>> A simpler and more efficient solution to comply with HTML parsers (which >>> might consider </ as introducing a closing tag) is: >> >> The proper terms are _end tag_ and End Tag Open (ETAGO) delimiter, >> respectively. ETAGO in script code is only necessary to be escaped if the >> code is in an HTML < 5 document. >> >> Nowadays the easiest and – for several reasons – recommended way to work >> around this is to include a script resource. In my experience, over time >> inline script code soon grows too much so that it is moved to an included >> script resource. There are other potential advantages of the latter, such >> as parallel loading and better editor support. This application, being >> small, and the script code limited to a single purpose, may be an >> exception. >> >>> blah.innerHTML += "<\/B>" >>> >> […] >>> [1] <http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1> >>> [2] <http://www.w3.org/TR/html5/scripting-1.html#the-script-element> >> >> Read more carefully before you cite: >> >> <http://www.w3.org/TR/2012/CR-html5-20121217/syntax.html#syntax> >> <http://www.w3.org/TR/2012/CR-html5-20121217/syntax.html#script-data-state> > > Latest – as cited: > > <http://www.w3.org/TR/2013/CR-html5-20130806/syntax.html#syntax> > <http://www.w3.org/TR/2013/CR-html5-20130806/syntax.html#script-data-state> > Thank you all for all the help and comments. I hired a local programmer, and he rewrote the entire code in about 30 minutes. Jim Rojas --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.javascript
csiph-web