Katipo Project Survival Kit

Katipo Developers Blog

Archive for June, 2006

Using a simple js checker for required form fields

Monday, June 26th, 2006

This is just a little js that I was working on to make a form check more portable.

To use it all you need to do is have id’s on your form fields and then for the required ones have this in the <form> tag

onsubmit=“return check_form(’formname’,'Title|Date|Name’)”

where ‘formname’ is the name of the form and the id’s you want to check are a listed separated by a |

and using the js

<script type=“text/javascript” />   // Function to grab inputs from specified fields by ID  // and check to see if they are blank and alert user if they are   function check_form(formname,ids)  {  var alert_str=”;  var idarray = ids.split("|");    for(var i=0;i  var fieldvalue = document.getElementById(idarray[i]).value;    if(fieldvalue ==”){  alert_str += idarray[i] + " is required\n";   // colour the field to help user    document.getElementById(idarray[i]).style.backgroundColor = "#FACADE";  } else {    // colour the field back to default -change if not white    document.getElementById(idarray[i]).style.backgroundColor = "#FFFFFF";  }  }   if(alert_str ==”){  eval("document."+formname+".submit()");    }    else {  alert(alert_str);  return false; }   //   <script />
 

It doesn’t tell you if the input is valid though just if it exists or not

Reverting a file that has been deleted by accident

Friday, June 23rd, 2006

A little known kea hack. If you delete a file, you can reinstate it yourself by making a new file with exactly the same file name as the old file. It doesn’t matter what Page title and meta information you give it on the Edit Info screen, just go through and save.

(more…)

Playing with CGI::Ajax

Friday, June 23rd, 2006

So last night, for the fun of it, I tried to build the Koha opac title search using Ajax. And with the help of the most excellent CGI::Ajax module, I ended up with a module Koha::Ajax which is 138 lines long, most of that is pod and html. (more…)

Weird problem with a warn statement and Apache

Thursday, June 22nd, 2006

So a couple of nights ago we came across a weird problem. A chunk of code in one of the Koha modules was causing a script that called it to hang. Only when called from the web though, it works fine from the command line. (more…)


Katipo Developers Blog is proudly powered by WordPress
Entries (RSS) and Comments (RSS).