• 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/

    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)
  • 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.