Re: I thought this would be easy - HELP
- From: "RobG" <rgqld@xxxxxxxxxxxx>
- Date: 19 Mar 2007 19:55:37 -0700
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
.
- References:
- I thought this would be easy - HELP
- From: EJ
- Re: I thought this would be easy - HELP
- From: VK
- Re: I thought this would be easy - HELP
- From: EJ
- I thought this would be easy - HELP
- Prev by Date: Re: I thought this would be easy - HELP
- Next by Date: Re: I thought this would be easy - HELP
- Previous by thread: Re: I thought this would be easy - HELP
- Next by thread: I thought this would be easy - HELP
- Index(es):
Relevant Pages
|