Crazy Amazing League Forum

Members: 474
Threads: 1,422
Posts: 16,275
Newest Member: The_LegendKiller Total Online: 15

Go Back   Crazy Amazing League Forum > Everything Else > Tech Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2010, 12:17 AM
Wombat's Avatar
Wombat Wombat is offline
PokéFan
 
Join Date: Oct 2009
Location: I'm actually the giant squid right behind you. But don't turn around.
Posts: 128
Default Help with Javascript

I'm not sure if this forum is just for CAL tech issues or not, sorry.

So as a new JS programmer, I am trying to design a simple forum of sorts. My problem is that I want the comments to stay permanently. I am guessing I would do that by using document.write, but my script relies on more of getElementById from the fields and innerHTML. I am just looking for a simple way to INCORPORATE document.write into my script.

Here's my HTML:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>Untitled Document</title>
	
		<script src="commentwrite.js" type="text/javascript" language="javascript">
		</script>
	</head>
	<body>
	
		<h1>Discussion</h1>
			<h2>Strategy</h2>
				<div id="talk">
					
				</div>
				
				<br>
				<br>
				
				<form action="">
					<fieldset>
						<legend>Select your code name (if it is not there than contact the webmaster):</legend>
						<select name="identity" id="usrnm">
							<option value="Bob">Bob</option>
							<option value="Joe">Joe</option>
						</select>
					</fieldset>
					<fieldset>
						<legend>Enter the secret password</legend>
						<input type="password" maxlength="14" id="passwrd">
					</fieldset>
					<fieldset>
						<legend>Enter your comment</legend>
						<input type="textarea" rows="6" cols="45" id="comment">
					</fieldset>
					<input type="button" onClick="writeComments()" value="Submit Comment">
				</form>
	
	</body>
</html>
And my script:
Code:
function writeComments() {
	var usrnm = document.getElementById("usrnm");
	var passwrd = document.getElementById("passwrd");
	var cmmnt = document.getElementById("comment");
	
	var username = usrnm.value;
	var password = passwrd.value;
	var comment = cmmnt.value;
	
	if (password == "password") {
		var talk = document.getElementById("talk");
		
		var result = "";
		result += talk.innerHTML;
		result += "<br>"
		result += "<b>" + username + "<\/b> says: \n";
		result += "<i>" + comment + "<\/i>";

		var output = document.getElementById("talk");
		output.innerHTML = result;
	} else {
		alert("Invalid Password");
	}
}
Note that it works except for the above problem.

Thanks.
__________________


GYMS: MajeSan-Buzz-KiwiDean
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. All times are GMT. The time now is 02:53 AM.
A vBSkinworks Design