2 Replies Latest reply: Nov 18, 2013 9:22 AM by capitanu
AdamKasprzak Level 1 Level 1 (0 points)

Hello!

 

I have a small page+javascript which I want to implement to wiki page. I have elliminated problem with html tags filtering (whitelist.plist) with disabling filtering at all. Now I face another problem. Script is not working. I have read manual which says that I should implement java as a file in template folder, but I don't really get it. Could sb explain. I would appreciate any help!

 

Script looks like this:

 

<form>

<input onclick="clickCh(this)" type="checkbox" name="one" value="10"> $10.00<br>

<input onclick="clickCh(this)" type="checkbox" name="two" value="12"> $12.00<br>

<br>

<input id="total" type="text" name="total">

</form>

 

<script language="JavaScript" type="text/javascript">

var total = document.getElementById("total")

function clickCh(caller){

if(caller.checked){

add(caller)

} else {

subtract(caller)

}

}

function add(caller){     total.value = total.value*1 + caller.value*1}

function subtract(caller){     total.value = total.value*1 - caller.value*1}

</script>

 

 


Mac mini, Mac OS X (10.6), Mac OSX Server Snow Leopard
  • AdamKasprzak Level 1 Level 1 (0 points)

    Ok, I have figured it out - You need to put your function:

     


    var total = document.getElementById("total")

    function clickCh(caller){

    if(caller.checked){

    add(caller)

    } else {

    subtract(caller)

    }

    }

    function add(caller){     total.value = total.value*1 + caller.value*1}

    function subtract(caller){     total.value = total.value*1 - caller.value*1}

     

     

    into a file, paste it into your theme directory, and change your html like this:

     

     

    <form>

    <input onclick="clickCh(this)" type="checkbox" name="one" value="10"> $10.00<br>

    <input onclick="clickCh(this)" type="checkbox" name="two" value="12"> $12.00<br>

    <br>

    <input id="total" type="text" name="total">

    </form>

     

    <script src="pricelist.js" type="text/javascript"></script>

     

  • capitanu Level 1 Level 1 (35 points)

    and moving on to Mavericks, where there are no more themes, any way to run a script?