Real Age calculators have become all the rage lately and so I decided to reverse engineer (and improve) a popular one (http://www.poodwaddle.com/realage.htm .) The poodwaddle calc is made in flash, but I made mine in php and javascript with an XML backend. Below is the code I used to read the Real Age XML into a PHP array. (oh, and you’ll also need the PHP XML parsing class from php.net.)

(http://healthtech.accordingtome.com/parseData.inc.phps)

if (!isset($_SESSION['questionArray'])) //cache
{
$lookupTable=array();
foreach($xml->children[0]->children as $lookup)
{
  if ($lookup->name=='row')
    $lookupTable[$lookup->attributes["input"]]=$lookup->attributes["output"];
}
 
$questionArray=array();
foreach($xml->children[1]->children as $questions)
{
  $tempQuestion=new Question();
  $tempQuestion->title=$questions->children[0]->content;
  $tempQuestion->prompt=$questions->children[1]->content;
  $tempQuestion->genderSpecific=$questions->children[2]->content;
  $tempQuestion->controllable=$questions->children[4]->content;
  $tempQuestion->options=array();
  foreach($questions->children[3]->children as $option)
    {
      $optionPrompt=$option->attributes["prompt"];
      $RAEffect=$option->attributes["RA-effect"];
      $tempQuestion->options[$optionPrompt]=$RAEffect;
    }
  $questionArray[]=$tempQuestion;
}
$_SESSION['questionArray']=$questionArray;
$_SESSION['lookupTable']=$lookupTable;
}

The actual Real Age code is pretty ugly, but I’ll post it as soon as I clean it up. Yes it works in IE and FF. Yes, the javascript slider code is slow (but it works!). It’s from the dojokit. It was the only vertical slidebar that allowed custom labels I could find.