Title: Javascript Calculator problem
Last modified: August 31, 2016

---

# Javascript Calculator problem

 *  [Cascade Design](https://wordpress.org/support/users/cascade-design/)
 * (@cascade-design)
 * [10 years ago](https://wordpress.org/support/topic/javascript-calculator-problem/)
 * Hi there.
 * Im running a very simple script that allows visitors to the site to input the
   size of their garden and get a quote.
 * It used to work on the old wordpress website, but now its not.
 * Its in swedish, but the code is shown below, and is live here:
 * [http://www.goodlawns.se/price-calculator/](http://www.goodlawns.se/price-calculator/)
 * where it says: Storlek på gräsmattan, thats where you put your number and press
   Calc.
 * Im not a coder, expecially in JS, this was done by a friend a while ago. so be
   gentle with me?
 * It works when i put it into notepad++ and open it in firefox etc, so im thinking
   its a wordpress issue?
 * this is the code
 * <script language=”javascript” type=”text/javascript”>
 * function calcquote(){
 * a=Number(document.calculator.area.value);
 * var scaleprice = 2.85;
 * var base = 2.85;
 * if (a > 1200)
 * {
 *  scaleprice = 1.65;
 * }
 * var base2 = scaleprice * a;
 * var scarify2 = 3 * base2;
 * var aerate2 = 2 * base2;
 * document.calculator.total.value=base2;
 * document.calculator.total2.value=scarify2;
 * document.calculator.total3.value=aerate2;
 * }
 * </script>
 * </head>
 * <body>
 * <!– Opening a HTML Form. –>
 * <form name=”calculator”>
 * <!– Here user will enter 1st number. –>
 * Storlek på gräsmattan: <input type=”text” name=”area”>
 * <!– Here result will be displayed. –>
 * Grundbehandling: <input type=”text” name=”total”>
 * Vertikalskärning pris: <input type=”text” name=”total2″>
 * Pipluftning pris: <input type=”text” name=”total3″>
 * <input type=”button” value=”Calc Quote” onclick=”javascript:calcquote();”>
 * </form>
 * </body>

Viewing 1 replies (of 1 total)

 *  [Jeffrey de Wit](https://wordpress.org/support/users/cheffheid/)
 * (@cheffheid)
 * [10 years ago](https://wordpress.org/support/topic/javascript-calculator-problem/#post-7442975)
 * Hey there,
 * What seems to be happening is that the script is being treated by the ol’ auto_p
   function. This means that all your lines of the script are being wrapped in HTML
   paragraph tags. Which, in turn, breaks the script.
 * Ideally, you’d put the script in its own file and enqueue it so that it won’t
   ever be an issue again. But as a quick fix, you can remove all the line breaks
   from the script and make sure the entire thing is on one line together with the
   script tags.

Viewing 1 replies (of 1 total)

The topic ‘Javascript Calculator problem’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [js](https://wordpress.org/support/topic-tag/js/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Jeffrey de Wit](https://wordpress.org/support/users/cheffheid/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/javascript-calculator-problem/#post-7442975)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
