Returning values from check boxes/pull down menus
So, I'm rather new to JS, only having first been introduced this fall semester, and have run into some major (to me) stumbling blocks.
Here's the code for a contact/opinion form we had to make, but I'm unable to return the selected info from the check boxes and pull down menus whenever attempting to print the for data at the end to confirm before submitting.
Code:
<html>
<head>
<title>Contact Form</title>
</head>
<body bgcolor="lightblue">
<h2 align="center">
<font color="green">
Contact Us
</font>
</h2>
<form name="TWP" ACTION="mailto:emailaddress@school.edu?SUBJECT=Assignment" METHOD="post" ENCTYPE="text/plain">
<p>
<u>What is your name?</u>
</p>
<p>
<input TYPE="text" NAME="yourName" ID="yourName" value="insert name" size="20" maxlength="30" />
</p>
<p>
<u>Questions? Comments?</u>
</p>
<p>
<TEXTAREA cols="25" rows="5" wrap="hard" ID="comments">
</TEXTAREA>
</p>
<p>
<u>Did you enjoy our web page?</u>
</p>
<input type="radio" NAME="webpage" ID="webpage" VALUE="Yes" /> Yes
<input type="radio" NAME="webpage" ID="webpage" VALUE="No" /> No
<input type="radio" NAME="webpage" ID="webpage" VALUE="No Comment" /> No comment
<br>
<p>
<u>Which of our products do you use?</u>
</p>
<input type="checkbox" NAME="products" ID="products" VALUE="Milk" /> Milk
<input type="checkbox" NAME="products" ID="products" VALUE="Cheese" /> Cheese
<input type="checkbox" NAME="products" ID="products" VALUE="Butter" /> Butter
<input type="checkbox" NAME="products" ID="products" VALUE="Sour Cream" /> Sour Cream
<input type="checkbox" NAME="products" ID="products" VALUE="Ice Cream" /> Ice Cream
<br>
<p>
<u>Favorite Kind of Cheese?</u>
</p>
<select name="cheese" id="pulldown1" size="5" style="width:100px">
<option>Swiss</option>
<option>American</option>
<option>Provolone</option>
<option>Mozzarella</option>
<option>Cheddar</option>
</select>
<br>
<p>
<u>Favorite Kind of Ice Cream?</u>
</p>
<select name="icecream" id="pulldown2" size="5" style="width:150px">
<option>Vanilla</option>
<option>Chocolate</option>
<option>Strawberry</option>
<option>Cookies and Cream</option>
<option>Cookie Dough</option>
</select>
<br>
<br>
<h2>
<font color="green">
You have selected:
</font>
</h2>
You have entered the name:
<font size="2">
<span id="span0">
<i>Your Name</i>
</span>
</font>
<br>
Your questions/comments are the following:
<font size="2">"
<span id="span1">
<i>Questions or Comments</i>
</span>
"</font>
<br>
Did you enjoy your stay on our page?:
<font size="2">
<span id="span2">
<i>Enjoyed?</i>
</span>
</font>
<br>
You use the following of our product(s):
<font size="2">
<span id="span3">
<i>Products Used</i>
</span>
</font>
<br>
Your favorite cheese is:
<font size="2">
<span id="span4">
<i>Favorite Cheese</i>
</span>
</font>
<br>
Your favorite ice cream is:
<font size="2">
<span id="span5">
<i>Favorite Ice Cream</i>
</span>
</font>
<br>
<br>
<button onclick="FV()">Click to review selections.</button>
<br>
<br>
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
<br>
</form>
<!--Script-->
<script type="text/javascript">
function FV() {
var yourName = document.getElementById("yourName");
var comments = document.getElementById("comments");
var webPage = document.getElementById("webpage");
var products = document.getElementById("products");
var favCheese = document.getElementById("pulldown1");
var iceCream = document.getElementById("pulldown2");
document.getElementById("Span0").innerHTML = yourName.value;
document.getElementById("Span1").innerHTML = comments.value;
document.getElementById("Span2").innerHTML = webPage.value;
document.getElementById("Span3").innerHTML = products.value;
document.getElementById("Span4").innerHTML = favCheese.value;
document.getElementById("Span5").innerHTML = iceCream.value;
}
</script>
<!--/Script-->
</body>
</html>
Re: Returning values from check boxes/pull down menus
I don't see anything to do with Java in your post. You do know that Java and JavaScript are two completely different languages, and you appear to be asking a JavaScript question in a Java forum. Consider Googling for a JavaScript forum and asking this question there.