Welcome, Guest
Username: Password: Remember me
The place for more technical questions for those who want to create new pagetypes or bespoke functionality.

TOPIC: Useful Code Snippets

Useful Code Snippets 10 months 3 weeks ago #5157

  • Helen Davies
  • Helen Davies's Avatar
  • Offline
  • Senior Boarder
  • Posts: 66
  • Thank you received: 3
Hi all,

I'm not sure if this is the correct place for this, or whether it should be in the Creating Effective Materials section, but following sessions at the training day and the Xerte conference about coding and adding extra code and javascript to Xerte learning objects, I thought it might be a good idea to start a thread to share useful tips and bits of code that could be used in Xerte.

I will contribute some when I've sorted mine out, but if you are posting code, please could you indicate what it does, and if possible, attach a screenshot.

The administrator has disabled public write access.
The following user(s) said Thank You: Graeme Samuels

Useful Code Snippets 10 months 2 weeks ago #5185

  • Fay
  • Fay's Avatar
  • Offline
  • Expert Boarder
  • Posts: 149
  • Thank you received: 47
Not a complicated bit of code but adding this link will refresh the project. It's useful if you are using variables in questions & want the project to be refreshed so that the variables are recalculated & the question will update
<a href="#" onclick="location.reload()">Try again</a>
The administrator has disabled public write access.
The following user(s) said Thank You: Yvonne Moore

Useful Code Snippets 10 months 1 week ago #5191

  • Yvonne Moore
  • Yvonne Moore's Avatar
  • Offline
  • Junior Boarder
  • Posts: 26

I found this on the web and used it for an activity where users had to practice composing a tweet. It does the character countdown.
<style type="text/css">.over {
  color: red;
<script type="text/javascript">maxCharacters = 140;
  $('textarea').bind('keyup keydown', function() {
    var count = $('#count');
    var characters = $(this).val().length;
    if (characters > maxCharacters) {
    } else {
    count.text(maxCharacters - characters);
<p><span style="font-size:12px;"><i>You have <span id="count"></span> characters remaining</i></span>
The administrator has disabled public write access.
Moderators: John Smith
Time to create page: 0.367 seconds
Powered by Kunena Forum


Sponsor us

The Xerte Community is a volunteer-based organization. Please help us to continue that!