[Web4lib] library calculator/java question

Andrew amutch at waterford.lib.mi.us
Mon Mar 23 15:47:11 EDT 2009


Richard,

There's a few clean-up items in your code that once you correct should 
leave you with a working script:

1) Move the entire chuck of Javascript between the <script> </script> 
tags to the top of your page so that it's listed before the <BODY> tag. 
What happens when you click on the "Calculate The Value of Your Library 
Use" button is that it calls the script. But right now, your script 
appears after that button so it's not processed which results in the 
error message.

2) The entire line of:

var totalValue = (document.calculator.booksResult.value*1) + 
(document.calculator.paperResult.value*1) + ...

needs to be in a single line. You have line breaks after each "+" sign. 
If you're not seeing those breaks, turn off "Word Wrap" in the editor 
that you are using. Delete all of the line breaks so it appears as one 
big long string.

3) There's a reference to this in the code:
var auditoriumValue = document.calculator.auditorium.value * 250.00;
document.getElementById("auditoriumResult").value = 
auditoriumValue.toFixed(2);

but no form fields that correspond to it. Either remove that code there 
and in the function doCalculator:

 + (document.calculator.auditoriumResult.value*1)

or add the appropriate form fields.

4) At the end of this code, there's a stray "var". Delete it.

var audiobooksValue = document.calculator.audiobooks.value * 30.00;
document.getElementById("audiobooksResult").value = 
audiobooksValue.toFixed(2); var

5) I found that at least one browser didn't like it when your code is 
like this:

var illValue = document.calculator.ill.value * 30.00; 
document.getElementById("illResult").value = illValue.toFixed(2);

Add a link break after the semi-colon so that it appears as:

var illValue = document.calculator.ill.value * 30.00;
document.getElementById("illResult").value = illValue.toFixed(2);

With those changes, you should be good to go. Good luck!

Andrew Mutch
Library Systems Technician
Waterford Township Public Library
Waterford, MI


Richard James wrote:
> I'm trying to install a "library value calculator" on my own site, with next
> to no knowledge of java. Any guidance gladly accepted.
> I carefully cribbed and cleaned up source code from the standard calculator
> as provided by Maine, but I'm pretty sure I must be missing something
> important because none of the total fields will calculate at all:
>
> http://lib.de.us/libraryvalue.html
>
> grateful for any help!
>
> Richard James
> _______________________________________________
> Web4lib mailing list
> Web4lib at webjunction.org
> http://lists.webjunction.org/web4lib/
>
>   




More information about the Web4lib mailing list