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

Smith, John J.J.Smith at gcu.ac.uk
Tue Apr 28 13:24:15 BST 2015


Hi,

There is a problem with line breaks being converted to <br> tags, usually this is  desirable... inside script tags it is definitely not...

My advice Kent would be to learn some jQuery... for your application, in its simplest form

Add up Carbs:
<input type="text" id="qty1"/><br>
<input type="text" id="qty2"/><br>
<br><br>
Total : <input type="text" id="total"/>
<script>$('input').blur( function() { $('#total').val(Number($('#qty1').val()) + Number($('#qty2').val())); });</script>

Paste that into any text box and it should work...

Regards,

John Smith | Learning Technologist
Room A250, Govan Mbeki Building | School of Health & Life Sciences | Glasgow Caledonian University
Cowcaddens Road | Glasgow | G4 0BA

Please address ALL support requests to hlsblt at gcu.ac.uk where one of the School Learning Technologists will pick up the job. This will ensure that all jobs are completed as promptly as possible.
________________________________________
From: xerte-bounces at lists.nottingham.ac.uk [xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Julian Tenney [Julian.Tenney at nottingham.ac.uk]
Sent: 28 April 2015 13:20
To: Xerte discussion list
Subject: [Xerte] Re: XOT 101 - Adding HTML/JS to a Text Page

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




This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it.

Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.

This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.


Glasgow Caledonian University is a registered Scottish charity, number SC021474



More information about the Xerte mailing list