Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value comparison must return greater value returns no value 2

Status
Not open for further replies.
Sep 12, 2007
143
US
Hi All, I'm trying to write a very simple script that will compare 2 values and return the greater of the two in a PDF form. So far, nothing I try will return a value.

It is a sales commission worksheet, where MinCommDue is a manually entered value that may or may not be populated (but is for my testing).
AllComs is a hidden field that is the sum of 4 other fields.

I need to compare the values and place whichever is greater in a different field.

I am very inexperienced in JS, any help would be greatly appreciated.

Here is the script:

var a=this.getField("MinCommDue");
var b=this.getField("AllComs");
if ((a.value >= b.value)){
event.value = a
} else {
if ((a.value <= b.value)) {
event.value = b
}
}
 
cFlaVA, It still gave me a syntax error unless I had the { before "alert". I also had to figure out how to subtract several other values from the original Max value, but that was easy enough that I figured it out. Thanks again!
 
That would create unbalanced brackets. Are you sure you copied this right?
 
MikeyJudd, you're right, I must not have copied it right or something. I copied it again and didn't get the error when I pasted it. Thanks!
 
Thanks :) I started another thread though, on the next problem. Can you recommend any good training or books that I might want to take advantage of? Free is good <g>.
 
In regards to the books, let me ask you this first: Are you part of a group or can you get a group of people from work together that have the same interests?

If so, you can check out User Groups from O'Reilly. You get free books, however you need to write some book reviews. To be honest, that isn't a bad trade.

Otherwise, check out half.com or amazon.com for good deals.
 
Hi Mikey, sadly, I am in a rather small town environment now (originally from KC). I am an entire IT department for a marina, so I have NO peers. Heck, half the people we know here can barely turn on a computer. My background is in PC hardware/software and networking, 11 years. Programming, just a tiny bit over the last 2 years, HTML, JS & PHP, but I'm extremely reliant on forums and tutorials...I have an older book at home on JS, maybe I should pick it up <g>.
 
Well, with the advancement of JavaScript I would recommend getting some new books.

But if you are going to do a lot of JS on webpages, I would recommend looking at a JS library. They already wrote the code for you! :eek:)

The best one out the, IMO, is Dojo []. We use this a lot at work and it is simply amazing.

Wish the best to you.
 
Mikey, thanks! I would be lost without the forums, and tek-tips is a standout :) I will check out the link, too. Most of the JS programming I am doing is actually for PDF fillable forms, my boss doesn't understand that it sometimes gets pretty complicated (at least for me), she just asks for what she wants and I try to provide it.
 
I have seen this post in other threads just with other names for the variables.. I it a school work or what??
BTW, the event.value would throw an error since the event is a predifined object and does not have a value property...

- Lowet

[gray]Why can't all browsers parse pages the same way? It should be the Web designer who decides how to display the content, not the browser![/gray]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top