[Xerte] Re: XOT 101 - Adding HTML/JS to a Text Page

Julian Tenney Julian.Tenney at nottingham.ac.uk
Tue Apr 28 13:20:48 BST 2015


I put this in an embed Content page and it works - it didn't work in a plain text page...

<p>Adding Numbers</p>
<input onblur="add();" type="text" id="txt1"/>
<input onblur="add();" type="text" id="txt2"/>
<input type="text" id="txt3"/>

<script>

function add(){

  alert("adding" + document.getElementById('txt1').value + " and " + document.getElementById('txt2').value);

}

</script>

From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Kent
Sent: 28 April 2015 12:32
To: Xerte Lists
Subject: [Xerte] XOT 101 - Adding HTML/JS to a Text Page

I need a page with a few input fields.  I want to sum the numbers from the fields into a total field.  Easy enough to add the fields to a Text page by putting the following into the "Page Text" field.

Add up Carbs:
<input onblur="findTotal()" type="text" name="qty" id="qty2"/><br>
<input onblur="findTotal()" type="text" name="qty" id="qty2"/><br>
<br><br>
Total : <input type="text" name="total" id="total"/>

To define the FindTotal() routine, I need to add a <script> section.

<script type="text/javascript">
    function findTotal(){
     // some JS code here
    }
</script>

As soon as I add the script section, the fields will no longer show up when I press Play.  I'm not sure what I'm doing wrong.

Any advice would be much appreciated.

Have a great day,
Kent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20150428/1c42a61d/attachment.html>


More information about the Xerte mailing list