Forums

ASP

This topic is locked

Creating a simple if statement

Posted 17 Mar 2003 20:59:37
1
has voted
17 Mar 2003 20:59:37 Andy Gorton posted:
Could someone please supply an ouline of some code that will create an if statement in forms.
e.g if a user enters 1000 in one form and then 2000 in an other, an if statement is needed to say
if form1 < form2 then print "message"
thanx in advance

Replies

Replied 17 Mar 2003 21:34:59
17 Mar 2003 21:34:59 Jørgen Emerslund replied:
Something like this?

<%
If Request.Form("textbox" < Request.Form("textbox2" Then Response.Write("Message"

%>

This is what you asked for in it's simplest form. You should probably check that you are dealing with two numbers first (hint: Use function CInt()) to have something to start with
Replied 19 Mar 2003 23:17:38
19 Mar 2003 23:17:38 Andy Gorton replied:
thanx dude
Replied 20 Mar 2003 00:02:34
20 Mar 2003 00:02:34 Andy Gorton replied:
I'm still having problems just to get a simple message to print from an if statement. Here is the code, could someone please point out where im going wrong
<form name="box1" method="post" action="">
<p>
<input name="box1" type="text" id="box1">
</p>
<p> </p>
</form>
<%
If Request.Form("box1" = "none"
Then Response.Write ("Message"
end if
%>
<p>  </p>
<input type="submit" name="Submit" value="Submit">
</form>

Replied 20 Mar 2003 03:19:05
20 Mar 2003 03:19:05 asp asp replied:
you have 2 closed form tags for starters and not sure what exactly you want to do, try this


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>

</head>

<body>
<form action="" method="post" name="box" id="box">
<p>
<input name="box1" type="text" id="box1" value=" ">
</p>

<%
If Request.Form("box1" = "none" Then Response.Write("your message here dude" end if
%>

<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

Reply to this topic