- Dec 1, 2000
- 181
- 0
- 0
I am working on some Java and I am just beginning for the most part. With what I have written so far, it prompts the user for name, address, and zip. It then asks if the user would like it displayed and if they do, it is displayed in an alert box. I need to do a check because I don't want it to display one of the fields if the user does not input anything for that particular value. How would I implement a check on this? Remember I am a newbie at Java so bear with me.
Code
<HTML>
<HEAD>
<TITLE>Assignment 4</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function gatherInfo(){
var address;
var name;
var zipcode;
var permission;
name=prompt("What is your name?","");
address=prompt("What is your street address?","");
zipcode=prompt("What is your Zipcode?","");
permission=confirm(confirmPermission(name,address,zipcode));
}
function confirmPermission(name,address,zipcode) {
var confirmation = confirm("Would you like to display your information?");
if (confirmation == true){
alert("Name:" +name +"\n" +"Address:" +address +"\n" +"Zip:" +zipcode);
thankYouMessage = thankYou();
}
else{
thankYouMessage = thankYou();
}
}
function thankYou(){
var displayPage;
document.writeln("<H1>Thank You</H1>");
displayPage=setTimeout("writeMessage(),5000");
}
function writeMessage(){
document.writeln("<H1>Display Web Page</H1>");
}
</SCRIPT>
</HEAD>
<BODY onLoad=gatherInfo();>
</BODY>
</HTML>
Code
<HTML>
<HEAD>
<TITLE>Assignment 4</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function gatherInfo(){
var address;
var name;
var zipcode;
var permission;
name=prompt("What is your name?","");
address=prompt("What is your street address?","");
zipcode=prompt("What is your Zipcode?","");
permission=confirm(confirmPermission(name,address,zipcode));
}
function confirmPermission(name,address,zipcode) {
var confirmation = confirm("Would you like to display your information?");
if (confirmation == true){
alert("Name:" +name +"\n" +"Address:" +address +"\n" +"Zip:" +zipcode);
thankYouMessage = thankYou();
}
else{
thankYouMessage = thankYou();
}
}
function thankYou(){
var displayPage;
document.writeln("<H1>Thank You</H1>");
displayPage=setTimeout("writeMessage(),5000");
}
function writeMessage(){
document.writeln("<H1>Display Web Page</H1>");
}
</SCRIPT>
</HEAD>
<BODY onLoad=gatherInfo();>
</BODY>
</HTML>
