www.webdeveloper.com
Results 1 to 2 of 2

Thread: how to seperate two programs on one page

  1. #1
    Join Date
    Sep 2013
    Posts
    26

    how to seperate two programs on one page

    Can I ask another question? I need to separate two programs on one page because I need both of them on one. I tried the <hr > and some other stuff but nothing works. It will not validate like it is. Any suggestions? Thank You

    Code:
    <!DOCTYPE html>
    <html lang="en">
    	<head>
    		<meta charset="utf-8" />
    		<title>Sentence Reverser</title>
    
    		<script type="text/javascript">
    
    			function sentenceReverser()
    			{
    				var word, words = [];
    				while (word = prompt('Enter a word for the sentence, Cancel to stop!', ''))
    				{
    					words.unshift(word);
    				}
    				document.reverseForm.output.value = words.join(' ');
    			}
    
    		</script>
    
    	</head>
    	<body>
    
    		<form name="reverseForm" action="#">
    			<label for="output">Reversed Sentence</label><br />
    			<input type="text" id="output" />
    			<input type="button" value="Run!" onclick="sentenceReverser();" />
    		</form>
    
    	</body>
    </html>
    break
    
    
    
    
    
    <!doctype html>
    <html>
    	<head>
    		<title>Temp Stats</title>
    		<meta charset="utf-8" />
    		<script type="text/javascript">
    		function do_work()
    {
    	var days = 0.0;
    	var dailyTemp = 0.0;
    	var highest = -Infinity;
    	var lowest = +Infinity;
    	var sum = 0.0;
    	
    	for (days = 1; days<= 5; days++)
    	{
    		dailyTemp = prompt("Enter the noon temp for the 5 days");
    		dailyTemp = parseInt(dailyTemp);
    		sum += dailyTemp;
    		var average = sum / days;
    		
    		lowest = (dailyTemp < lowest) ? dailyTemp : lowest;
    		highest = (dailyTemp > highest) ? dailyTemp : highest;
    	}
    	document.tempForm.highest.value = highest;
    	document.tempForm.lowest.value = lowest;
    	document.tempForm.average.value = average;
    }
    </script>
    	</head>
    	<body>
    		<form name="tempForm" action="#">
    			<label for="highest">Highest Temp: </label><br />
    			<input type="text" id="highest" />
    			<br />
    			<label for="lowest">Lowest Temp: </label><br />
    			<input type="text" id="lowest" />
    			<br />
    			<label for="average">Average Temp: </label><br />
    			<input type="text" id="average" />
    			<input type="button" value="Run!" onclick="do_work()" />
    			<br />
    		</form>
    	</body>
    </html>

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,441

    Lightbulb

    It is not possible with your current layout.
    You have, in effect, 2 programs in one file.
    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <title> Untitled </title>
    <meta charset="utf-8">
    
    </head>
    <body>
    
    </body>
    </html>
    Put your code in the appropriate positions with only one set of <HTML> and <body> tags.
    You can have multiple <script> and <div> and <input>, but not multiple <HTML> tags.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles