If all you're trying to do is to send the value of the str_questions
variable to the formmail script, you can have the form already written
in normal HTML in the page, and simply use Javascript to set the value
of the slidervalues element. You'll need to give your form a name,
such as "hiddenform" :
document.hiddenform.slidervalues.value=str_questions;
Lee,
except - after the last question has been answered I want the slider
values in the array to be sent without user action to the
formmail-nms.cgi script so that they can be sent to me via email.
I have code which does that using prototype.js etc but am trying to do
the same with a simple form...
The whole code using prototype.js follows - how would you use a form
in place of this?
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 type="text/javascript">
var mySlider1 = new Slider( "Slider1" );
var count = 0;
var slider_value = 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 lhs_questions = new Array(8)
lhs_questions[0]="I would often be in this situation";
lhs_questions[1]="I would often talk to a group of friends";
lhs_questions[2]="I would not worry if I stuttered here";
lhs_questions[3]="If I were to stutter here I would know why";
lhs_questions[4]="I would stutter mildy here";
lhs_questions[5]="If I were to stutter here, my friends would not be
able to tell";
lhs_questions[6]="If I were to stutter here I would feel bad";
lhs_questions[7]="If I were to stutter here, my group of friends would
be understanding";
var rhs_questions = new Array(8)
rhs_questions[0]="I would hardly ever be in this situation";
rhs_questions[1]="I would hardly talk to a group of friends";
rhs_questions[2]="I would worry if I stuttered here";
rhs_questions[3]="If I were to stutter here I would not know why";
rhs_questions[4]="I would stutter severly here";
rhs_questions[5]="If I were to stutter here, my friends would be able
to tell";
rhs_questions[6]="If I were to stutter here I would feel good";
rhs_questions[7]="If I were to stutter here, my group of friends would
not be understanding";
function buildTable()
{
document.write("<center>");
document.write("<table border='0' width='100%'>");
document.write("<tr>");
document.write(" <td ID='lhs_question' width='30%' valign='top'
height='70'>" + this.lhs_questions[count] + "</td>");
document.write(" <td width='40%' align='center' valign='top'
height='70'>" + "<IMG SRC='sliderbg.gif' NAME='Slider1RailImg'
ID='Slider1RailImg'>" + "</td>");
document.write(" <td ID='rhs_question' width='30%' valign='top'
height='70'>" + this.rhs_questions[count] + "</td>");
document.write("</tr>");
document.write("<tr><td colspan='3' align='center' valign='top'
height='100'>");
document.write("<input type='button' value='Next'
onclick='next_question(this)' />");
document.write("<SPAN class='invisible'
ID='Slider1ValueText'></SPAN>");
document.write("<SPAN ID='Status'></SPAN></td></tr>");
document.write("</table>");
document.write("</center>");
}
function next_question(button)
{
slider_value[count] = this.mySlider1.getValue(0);
this.count++;
if (this.count < 8)
{
document.getElementById('lhs_question').innerHTML =
this.lhs_questions[count];
document.getElementById('rhs_question').innerHTML =
this.rhs_questions[count];
mySlider1.setValue( (mySlider1.leftValue + mySlider1.rightValue) / 2
);
} else
{
if (button.parentNode &&
button.parentNode.removeChild) {
button.parentNode.removeChild(button);
}
saveIt();
}
}
function saveIt()
{
var str_questions = "";
for (var i=0; i < slider_value.length; i++)
{
str_questions += slider_value
+ "\n";
}
document.getElementById("Slider1ValueText").innerHTML =
str_questions;
var recipient = "extraemails";
var realname = "SPA Form";
var situation_value = "Social Group";
var url = 'http://website/path//formmail-nms.cgi';
var pars = 'recipient=' + recipient + '&' + 'realname=' + realname
+ '&' + 'Situation=' + situation_value + '&' + 'Name=' + name + '&' +
'Slider Values=' +
document.getElementById('Slider1ValueText').innerHTML;
var myAjax = new Ajax.Updater('Status', url, {method: 'post',
parameters: pars});
}
</script>
</HEAD>
<BODY onLoad="mySlider1.placeSlider()">
<h2 align="center">Social Group</h2>
<p align="center"><img src="pic3.jpg"></p>
<script language="javascript"
type="text/javascript">buildTable();</script>
<SCRIPT>
mySlider1.writeSlider();
</SCRIPT>
</body>
</html>