On Thu, 15 Sep 2005 13:51:19 +0200, ASM
Stephane,
My aplogies for changing the code so much. The code below is the
latest. You will see the preload code is different and don't think all
is well yet as it still takes a while for the pic0.jpg to display and
whilst that is happening the user can click on the "Next" button and
cause an error.
Probably I need to reinsert your preload code but could you just look
to see if that would follow through OK.
Cheers
Geoff
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<HEAD>
<link rel=stylesheet href="slider.css" type="text/css">
<SCRIPT SRC="slider.js"></SCRIPT>
<SCRIPT SRC="prototype-1.3.1.js"></SCRIPT>
<script src="questions.js"></script>
<script type="text/javascript">
var myImages = new Array();
var numImages = 7;
for (var z=0; z<numImages; z++)
{
myImages[z]=new Image();
myImages[z].src="pic" + z + ".jpg";
}
var mySlider1 = new Slider( "Slider1" );
var count = 0;
var situation_number = 0;
var slider_value = new Array(8);
for (var n = 0; n < slider_value.length; n++ ) {
slider_value[n] = new Array(8);
}
mySlider1.leftValue = -10;
mySlider1.rightValue = 10;
mySlider1.defaultValue = 0;
mySlider1.offsetX = 1;
mySlider1.offsetY = 1;
mySlider1.buttonWidth = 10;
mySlider1.maxSlide = 288;
mySlider1.onchange
="document.getElementById('Slider1ValueText').innerHTML
=''+this.getValue(0)";
var title = new Array(7);
title[0] = "Social Individual";
title[1] = "Formal Individual";
title[2] = "Social Group";
title[3] = "Formal Group";
title[4] = "Parents";
title[5] = "Telephone";
title[6] = "'Scripted' Conversations";
function next_question(button)
{
slider_value[situation_number][count] = this.mySlider1.getValue(0);
//totalreadings += ' ' + this.mySlider1.getValue(0);
this.count++;
if (this.count < 8)
{
document.getElementById('lhs_question').innerHTML = window["lhs_" +
situation_number][count];
document.getElementById('rhs_question').innerHTML = window["rhs_" +
situation_number][count];
mySlider1.setValue( (mySlider1.leftValue + mySlider1.rightValue) / 2
);
} else {
situation_number++;
if (situation_number < 7)
{
mySlider1.setValue(
(mySlider1.leftValue + mySlider1.rightValue) / 2 );
count=0;
fillTable();
} else {
if (button.parentNode
&& button.parentNode.removeChild) {
button.parentNode.removeChild(button);
}
saveIt();
}
}
}
function fillTable()
{
document.getElementById('title').innerHTML = "<h2>" +
title[situation_number] + "</h2>";
document.getElementById('picture').innerHTML = "<img src ='" +
myImages[situation_number].src + "' />";
document.getElementById('lhs_question').innerHTML = window["lhs_" +
situation_number][count];
document.getElementById('rhs_question').innerHTML = window["rhs_" +
situation_number][count];
}
function saveIt()
{
document.getElementById("Slider1ValueText").innerHTML = "";
for (situation_number = 0; situation_number < 7;
situation_number++)
{
document.getElementById("Slider1ValueText").innerHTML
+= escape("\n") + "Situation: " + title[situation_number] + " ";
for (var i = 0; i <
slider_value[situation_number].length; i++)
{
document.getElementById("Slider1ValueText").innerHTML
+= this.slider_value[situation_number]
+ ' ';
}
}
var recipient = "extraemails";
var realname = "SPA Form";
var url = 'http://website/path/formmail-nmst.cgi';
//var pars = 'recipient=' + recipient + '&' + 'realname=' +
realname + '&' + 'Name=' + name + '&' + 'Slider Values= ' +
document.getElementById('Slider1ValueText').innerHTML;
var pars = 'recipient=' + recipient + '&' + 'realname=' +
realname + '&' + 'Name=' + name + '&' + 'Slider Values=' +
document.getElementById("Slider1ValueText").innerHTML
var myAjax = new Ajax.Updater('Status', url, {method: 'post',
parameters: pars});
}
function sendButton()
{
document.write("<center>");
document.write("<table>");
document.write("<tr><td colspan='3' align='center' valign='top'
height='100'>");
document.write("<input type='button' name ='nextbutton' value='Next'
onclick='next_question(this)'>");
document.write("<SPAN class='invisible'
ID='Slider1ValueText'></SPAN>");
document.write("<SPAN ID='Status'></SPAN></td>");
document.write("</tr>");
document.write("</table>");
document.write("</center>");
}
</script>
</HEAD>
<body onload="mySlider1.placeSlider()">
<center>
<table border='0' width='100%'>
<tr>
<td> </td>
<td ID='title' valign='top' align='center'></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td ID='picture' valign='top'></td>
<td> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td ID='lhs_question' width='30%' valign='top' height='70'></td>
<td width='40%' align='center' valign='top' height='70'>
<IMG SRC='sliderbg.gif' NAME='Slider1RailImg'
ID='Slider1RailImg'></td>
<td ID='rhs_question' width='30%' valign='top' height='70'></td>
</tr>
</table>
</center>
<script>
fillTable();
sendButton();
</script>
<SCRIPT>
mySlider1.writeSlider();
</SCRIPT>
</body>
</html>