Go Back   CodingForums.com > :: Client side development > JavaScript programming > Post a JavaScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-14-2009, 03:00 PM   PM User | #1
hawkeye107
New to the CF scene

 
Join Date: Oct 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
hawkeye107 is an unknown quantity at this point
Use an Array to display random message with Username

Hello. I've done most of the coding by myself already but can't get the pieces together. I can display a random message via the array and I already have my text book and submit button done, but can't figure out how to get user input to be put where it should go. I've been on this thing for a few hours and I'm slowly pulling my hair out. Any help would be well appreciative. Thank you


<html>
<head>
<title>Random Message</title>

<script type="text/javascript">

var userMessages = new Array();
userMessages[0] = "Merry Christmas,";
userMessages[1] = "Happy Halloween, ";
userMessages[2] = "Happy New Years, ";
userMessages[3] = "Happy Easter, ";
userMessages[4] = "Happy Earth Day, ";
userMessages[5] = "Happy Valentine's Day";
userMessages[6] = "Happy Thanksgiving, ";
userMessages[7] = "Happy 4thh of July, ";
userMessages[8] = "Happy St. Patrick's Day, ";
userMessages[9] = "Happy Memorial Day, ";

window.onload = function ()
{
document.getElementById("generateUserMessage").innerHTML = userMessages[Math.floor(Math.random()*userMessages.length)];
}

/*function getUserName()
{
var userName;
userName = getElementById(userName);


}
*/

</script>
</head>


<body>
<div id="generateUserMessage"></div>


<form>
<h1>What is your name?</h1>

<input type ="text" id="userName" name="userName" size=10 >
<input type ="button" value="Submit" onClick="">

</form>


</body>
</html>
hawkeye107 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:58 PM.


Advertisement
Log in to turn off these ads.