Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Design Forum > HTML / CSS
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-27-2006, 01:09 AM   #1 (permalink)
CSUjr
Junior Member
 
Join Date: May 2006
Posts: 5
Default I need some help coding a Form

I am new to writing HTML.

I have read HTML tuts, looked at examples and tried different things, but I'm stuck on how to make my Form do what I need it to do.

I have a simple Form that a user inputs information in and clicks a submit button.

When the information is submitted, it must match a specific line of text (which is always the same and is specified somewhere within the code of that same page).

If the submitted information does not match the specified line of text, then I need to present a message to the user to enter the correct information.

If the submitted information does match the specified line of text, then I want to send the user to another (specified) page within the site.

This is what I have so far;

<html>
<body>
<form name="input" action="html_form_action.asp"
method="get">

<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
Enter your answer and click Go
</p>
<form>
Answer:
<input type="text" name="answer">
<input type="submit" value="Go">
</form>

Question>>>If the answer is not correct, what code do I need to put in here (???) to return a message like, "Please enter the correct answer"

Question>>>If the answer is correct, what code do I need to put in here (???) to send the user to a specified page within the site?

</font>
</body>
</html>

Also, is this the correct type of form for what I am trying to do? <form name="input" action="html_form_action.asp"
method="get">

Can anyone help by providing me with the code that I need to make this Form do what I need it to do?

Thank you,
Charles
CSUjr is offline   Reply With Quote
Sponsored Links
Old 05-27-2006, 02:54 PM   #2 (permalink)
CSUjr
Junior Member
 
Join Date: May 2006
Posts: 5
Default Re: I need some help coding a Form

Okay, this is what I have now.

It doesn't work, but I think that it's closer;

<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: small;
}
-->
</style>
</head>

<body>

<form name="input" action="html_form_action.asp" >
<p class="style1">
Enter your answer and click Go</p>


<span class="style1">Answer:</span>
<input type="text" name="answer">
<input type="submit" value="Go">

<% if request.form('answer')="correct answer"
<a href="success.html"></a>
<% else %>
<p class="style1">Please enter the correct answer</p>

<% end if %>
</form>
</body>
</html>

Can anyone please help me with the correct coding?
CSUjr is offline   Reply With Quote
Old 05-28-2006, 04:37 AM   #3 (permalink)
CSUjr
Junior Member
 
Join Date: May 2006
Posts: 5
Default Re: I need some help coding a Form

Okay, let me try again.

The code below sends the User to the desired page regardless of what is in the text box, and even if it is empty.

This means that I have not put the right information in the right place in this code.

I want it so that the User Must enter the correct information
if not, the User will receive a message such as; “Please enter the correct information”
if so, the User will be sent to the specified page


Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Answer Validation</title> <style type="text/css"> <!-- .style1 { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: small; } --> </style> </head> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- function validateForm() { var count=0; var msg="correct"; for(i=0;i<=4;i++) { if(document.UD.elements[i].value=="correct") { count=1; msg=msg+"\n"+document.UD.elements[i].name; } else if((i>3) && (count==0)) { return(true); } } for(i=0;i<=4;i++) { if(document.UD.elements[i].value=="correct") { alert("Please enter Correct Answer\n "+msg); document.UD.elements[i].focus(); return(false); } } } //--> </SCRIPT> </HEAD> <BODY> <FORM METHOD=POST ACTION="success.html" NAME="UD"> <TABLE ALIGN="CENTER"> <TR> <TD><span class="style1">Enter Correct Answer </span></TD> <TD><INPUT NAME="correct" TYPE="TEXT" size="40"></TD><TD><INPUT TYPE="SUBMIT" VALUE="Go" onClick="return validateForm()"></TD> </TR> </TABLE> </FORM> </BODY> </HTML>

Will someone please help me make this so that it works the way that I need it to?

Charles
CSUjr is offline   Reply With Quote
Old 05-31-2006, 04:59 PM   #4 (permalink)
webboc
Junior Member
 
webboc's Avatar
 
Join Date: May 2006
Posts: 8
Default Re: I need some help coding a Form

Hi Charles

Do you have PHP on your server?

Regards

webboc
webboc is offline   Reply With Quote
Old 05-31-2006, 05:26 PM   #5 (permalink)
webboc
Junior Member
 
webboc's Avatar
 
Join Date: May 2006
Posts: 8
Default Re: I need some help coding a Form

Hi Charles

Just in case you do not have PHP, try the script below.

The password is set to 'letmein'.

When correct, the user is sent to the success.htm page, when wrong they are asked to enter the correct information and the original page (answer.htm) is reloaded.

Hope this helps!

Kind regards

webboc


<form>
<p>Enter correct answer:
<input type="password" name="text1">
<input type="button" value="Go" name="Submit" onclick=javascript:validate(text1.value,"letmein") >
</p>
</form>
<script language = "javascript">
function validate(text1,text2)
{
if (text1==text2)
load('success.htm');
else
{
alert("Please enter the correct information");
load('answer.htm');
}
}
function load(url)
{
location.href=url;
}
</script>

Last edited by webboc : 05-31-2006 at 06:51 PM.
webboc is offline   Reply With Quote
Old 08-15-2006, 03:38 PM   #6 (permalink)
Broes
Junior Member
 
Join Date: Aug 2006
Posts: 7
Default Re: I need some help coding a Form

The problem with your code is that it does not verify whether or not the answers are correct. You need to let that check first. So then you can give the elements the value correct and then redirect like webboc wrote. So make sure you check if the answers are correct first. (which can be done in a similar way)
__________________
To become smarter, you must play someone smarter - Rule 1, Chess book 1878 (Revolver)
Broes is offline   Reply With Quote
Old 08-18-2006, 01:01 PM   #7 (permalink)
Lukeishere.com
Junior Member
 
Join Date: Aug 2006
Posts: 24
Default Re: I need some help coding a Form

Thanks alot everyone! I had another post for a promo code box and this would do the same thing for me!!
Lukeishere.com is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 12:55 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums