Re: I thought this would be easy - HELP



On Mar 20, 9:26 am, "EJ" <jordane...@xxxxxxxxxxx> wrote:
OK, part of the problem is that I don't know js well enough to state
the problem clearly. But I;ve chopped the code down ... The script
below tries to create variables via slice method take information from
selected options and use the info in functions which calucate values.
The values are then passed to inputs.
I've tried this several ways ... the first question is how should such
variables be declared?

In addition to what Randy said:


[...]
function cost()
{
var cpus = form.cpu.value.slice(8,10)
var shps = form.shp.value.slice(8,10)
var total = total(cpus,wars)

Here you declare a local variable total but also want access to a
function total() (presumably declared in the global space). The local
variable masks the function, so either change the name of the local
variable, or use:

var total = window.total(cpus,wars)


or some may suggest declaring a global variable right at the start of
the script with:

<script>
var _global = this;

function cost(){
...
var total = _global.total(...)
...
}


but that seems a bit excessive here - it is unlikely a form has a
useful context to an environment that doesn't have a window object.


form.systot.value=cost(total)

Where is form declared or given a value?


[...]

<body>
<form name="price" target="paypal" action="https://www.paypal.com/cgi-
bin/webscr" method="POST">

For the sake of debugging, the action and method should be empty.


--
Rob

.



Relevant Pages

  • Re: Compare IP addresses
    ... You cannot type variables when you declare them, ... > but the script didnt like that - that was the reason for setting the ... startoctet and endoctet werent declared either? ... >>> How do I compare two numbers in script? ...
    (microsoft.public.scripting.wsh)
  • cron script hangs after a while (seems to)
    ... these scripts from my package, ... Create an html page from the log created by the previous script. ... declare ip_src_table ...
    (comp.unix.shell)
  • RE: variable declaration, was RE: moving to the next line
    ... Declare them as you go. ... When taking programming classes in college, ... Several people on this list have discouraged the habit. ... their script before opening their text editor. ...
    (perl.beginners)
  • OO Perl Online Learning
    ... Is there no single place I can declare an entire set of classes for use ... What's all this about test suites? ... I can understand writing a script ... Should I *always* use strict and use warn? ...
    (comp.lang.perl.misc)