Newsroom Update

Beginning in May, a special Today at Apple series titled “Made for Business” will offer small business owners and entrepreneurs free opportunities to learn how Apple products and services can support their growth and success. Learn more >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

SL wiki server javascript

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

Posted on Apr 1, 2012 7:02 AM

Reply
Question marked as Best reply

Posted on Apr 1, 2012 7:25 AM

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>


2 replies
Question marked as Best reply

Apr 1, 2012 7:25 AM in response to AdamKasprzak

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>


SL wiki server javascript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.