PDA

View Full Version : Script Help Pleas


JeffG
10-16-2002, 08:23 PM
Hello,

Please forgive me if this is not the right forum for my question. It is my first day and I am still not sure were to go.

I am trying to find out why I can't get user information to appear in the script.

Any help would be appreciated.

<html>
<head>
<title>Questionaire</title>
</head>
<body>
<pre>
<script language="JavaScript" type="text/javascript">
<!--
var personal = new Array(7);
personal[0] = null;
personal[1] = null;
personal[2] = null;
personal[3] = null;
personal[4] = null;
personal[5] = null;
personal[6] = null;
var name = prompt ("Please enter your first and last name", "Enter your name here");
var address = prompt ("Please enter your address", "Enter address here");
var phone = prompt ("Please enter your phone number including area code", "Enter number here");
var city = prompt ("Please enter city", "Enter city here");
var state = prompt ("Please enter state", "Enter state here");
var zip = prompt ("Please enter your zip code", "Enter zip code here");
var occupation = prompt ("Please enter your occupation", "Enter occupation here");
for (var count = 0; count <personal.length; ++count) {
document.writeln(personal[count]);
}
//-->
</script>
</pre>
</body>
</html>


Thank you kindly

Jeff G

Spookster
10-16-2002, 08:35 PM
JeffG,

In the future please read our posting guidelines in reference to subject lines for threads.

http://www.codingforums.com/postguide.htm

The subject of your thread is very vague.

JeffG
10-16-2002, 08:37 PM
Once again, I do very much appologize.

Jeff G

requestcode
10-16-2002, 08:42 PM
You are not populating the array with the values you are collecting from the prompts. I have modified your script, try this:
<html>
<head>
<title>Questionaire</title>
</head>
<body>
<script language="JavaScript">
var personal = new Array(7);

personal[0] = prompt("Please enter your first and last name", "Enter your name here");
personal[1] = prompt("Please enter your address", "Enter address here");
personal[2] = prompt("Please enter your phone number including area code", "Enter number here");
personal[3] = prompt("Please enter city", "Enter city here");
personal[4] = prompt("Please enter state", "Enter state here");
personal[5] = prompt("Please enter your zip code", "Enter zip code here");
personal[6] = prompt("Please enter your occupation", "Enter occupation here");
for (count = 0; count <personal.length; count++) {
document.writeln(personal[count]);
}
</script>
</body>
</html>

JeffG
10-16-2002, 09:40 PM
Hello requestcode,

I can't thank you enough.

It looks like I was all over the place on this. I just never worked with input arrays before.

Once again, thank you and I hope you have a nice day!

Jeff G