Results 1 to 2 of 2
  1. #1
    nmac9 is offline Member
    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Default 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.

    Java 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>
    Last edited by nmac9; 12-03-2012 at 03:27 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default 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.

Similar Threads

  1. Result set not returning values
    By karthikeyan_raju in forum Advanced Java
    Replies: 5
    Last Post: 04-14-2011, 06:24 AM
  2. Retrieve values of Text boxes using LIST
    By Kayal in forum Web Frameworks
    Replies: 2
    Last Post: 03-20-2009, 12:00 PM
  3. problem on returning values..
    By kulangotski in forum Advanced Java
    Replies: 11
    Last Post: 03-07-2009, 03:13 AM
  4. Replies: 0
    Last Post: 12-01-2007, 12:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •