davenet
10-17-2005, 05:20 AM
Hi,
I've just written a small snippet of Javascript code which is supposed to open a new window and then write a String to the new window. Some of the string was captured from a form in the window that is calling the new one.
Since I couldn't get it to work, I went ahead and modified the code so that I'm just writing a plain string using double quotes. Here's my current line of code I'm using to write to the window:
dispWin.document.write("my message");
Here's the code so you can see the context.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Spokane Telephone Survey</title>
<script language="javascript" type="text/javascript">
<!-- Hide script from older browers
function submitForm() {
dispWin = window.open('','Confirm Survey Results','toolbar=no,status=no,width=600,height=400');
var q1Ind = document.surveyForm.spend.selectedIndex;
var q1 = document.surveyForm.spend.options[q1Ind].value;
message = "How much do you spend on long distance each month?" + q1;
dispWin.document.write(message);
dispWin.document.write("my message");
}
-->
</script>
</head>
<body>
<form id="surveyForm" onsubmit="submitForm()">
<div class="question">
How much do you spend on long distance each month?
</div>
<div class="answer">
<select name="spend">
<option value="" selected="selected">Select one...</option>
<option value="$10 or less">$10 or less</option>
<option value="$11 - $20">$11 - $20</option>
<option value="$21 - $30">$21 - $30</option>
<option value="$31 or more">$31 or more</option>
</select>
</div>
<div class="question">
Do you make mostly daytime or evening/weekend calls?
</div>
<div class="answer">
<select name="when">
<option value="" selected="selected">Select one...</option>
<option value="day">Day Calls</option>
<option value="evening">Evening/Weekend Calls</option>
</select>
</div>
<div class="question">
Please make any other comments you feel would be helpful in the space provided.
</div>
<div class="answer">
<textarea name="comments" cols="40" rows="6"></textarea>
</div>
<div class="processForm">
<input name="submit" type="submit" value="Submit" />
<input name="reset" type="reset" value="Reset" />
</div>
</form>
</body>
</html>
When the new window pops up, nothing ever gets written to it. Viewing the source just shows a blank HTML page with just the very barest of tags (html, head, body).
Not sure where I'm going wrong, but I am not having any luck figuring it out. I'm hoping someone can point me to where my problem is at.
David
I've just written a small snippet of Javascript code which is supposed to open a new window and then write a String to the new window. Some of the string was captured from a form in the window that is calling the new one.
Since I couldn't get it to work, I went ahead and modified the code so that I'm just writing a plain string using double quotes. Here's my current line of code I'm using to write to the window:
dispWin.document.write("my message");
Here's the code so you can see the context.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Spokane Telephone Survey</title>
<script language="javascript" type="text/javascript">
<!-- Hide script from older browers
function submitForm() {
dispWin = window.open('','Confirm Survey Results','toolbar=no,status=no,width=600,height=400');
var q1Ind = document.surveyForm.spend.selectedIndex;
var q1 = document.surveyForm.spend.options[q1Ind].value;
message = "How much do you spend on long distance each month?" + q1;
dispWin.document.write(message);
dispWin.document.write("my message");
}
-->
</script>
</head>
<body>
<form id="surveyForm" onsubmit="submitForm()">
<div class="question">
How much do you spend on long distance each month?
</div>
<div class="answer">
<select name="spend">
<option value="" selected="selected">Select one...</option>
<option value="$10 or less">$10 or less</option>
<option value="$11 - $20">$11 - $20</option>
<option value="$21 - $30">$21 - $30</option>
<option value="$31 or more">$31 or more</option>
</select>
</div>
<div class="question">
Do you make mostly daytime or evening/weekend calls?
</div>
<div class="answer">
<select name="when">
<option value="" selected="selected">Select one...</option>
<option value="day">Day Calls</option>
<option value="evening">Evening/Weekend Calls</option>
</select>
</div>
<div class="question">
Please make any other comments you feel would be helpful in the space provided.
</div>
<div class="answer">
<textarea name="comments" cols="40" rows="6"></textarea>
</div>
<div class="processForm">
<input name="submit" type="submit" value="Submit" />
<input name="reset" type="reset" value="Reset" />
</div>
</form>
</body>
</html>
When the new window pops up, nothing ever gets written to it. Viewing the source just shows a blank HTML page with just the very barest of tags (html, head, body).
Not sure where I'm going wrong, but I am not having any luck figuring it out. I'm hoping someone can point me to where my problem is at.
David