var htmlArray = [
"<form action='
http://website/path/formmail-nms.cgi'",
" method='post'><input type='hidden' name ='slidervalues'",
" value='" + str_questions + "'>",
"<input type='hidden' name='recipient' value='extraemails'>",
"<input type='submit' value='send'></form>"
];
document.write( htmlArray.join() );
The last way is probably the fastest as it avoids concatentation. All
should be faster than multiple calls to document.write (though perhaps
not noticeably so in this case) - over to you.
Rob,
I have used your last suggestion above but I still get the submit
button appearing in a new window! Perhaps you can see why from the
whole code below? In fact also get 2 commas in front of the button?!
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>
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' name ='nextbutton' 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 htmlArray = [
"<form action='http://wwebsite/path/formmail-nms.cgi'",
" method='post'><input type='hidden' name ='slidervalues'",
" value='" + str_questions + "'>",
"<input type='hidden' name='recipient' value='extraemails'>",
"<input type='submit' value='send'></form>"
];
document.write( htmlArray.join() );
}
</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>