473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Tricky Form Problem

I'm building a simple file management application using Classic ASP VBScript that has a
form to input page content, and file name.

After the form is submitted, the application will check to see if a page with that file
name already exists - if the file name already exists the user is quickly notified and
asked to provide a different file name for that page.

What I would like to do is, when the user submits the form, if the file name already
exists, stay on the form page (instead of changing to another page) and just have some
red letters next to the file name say "file name already in use".

Can anyone tell me how to do this???

Thanks,

Bill.
May 9 '07 #1
6 1743
Bill wrote:
I'm building a simple file management application using Classic ASP
VBScript that has a form to input page content, and file name.

After the form is submitted, the application will check to see if a
page with that file name already exists - if the file name already
exists the user is quickly notified and asked to provide a different
file name for that page.

What I would like to do is, when the user submits the form, if the
file name already exists, stay on the form page (instead of changing
to another page) and just have some red letters next to the file name
say "file name already in use".

Can anyone tell me how to do this???
Like this?

<%
dim FileName, msg
FileName=Request.Form("filename")
if len(FileName)0 then
if CheckForFile(FileName) then
msg="File name already used"
end if
end if
function CheckForFile(pfilename)
'put your code to check for the file here
'let's simulate it finding the file:
CheckForFile=true
end function
%>
<HTML>
<BODY>

<FORM action="" method=post>
<INPUT id=text1 name=filename value=" <%=filename%>">
<span style="FONT-SIZE: large; COLOR: red"><%=msg%>
</span><br>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>

</BODY>
</HTML>
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
May 9 '07 #2
"Bob Barrows [MVP]" wrote...
Bill wrote:
I'm building a simple file management application using Classic ASP
VBScript that has a form to input page content, and file name.

After the form is submitted, the application will check to see if a
page with that file name already exists - if the file name already
exists the user is quickly notified and asked to provide a different
file name for that page.

What I would like to do is, when the user submits the form, if the
file name already exists, stay on the form page (instead of changing
to another page) and just have some red letters next to the file name
say "file name already in use".

Can anyone tell me how to do this???

Like this?

<%
dim FileName, msg
FileName=Request.Form("filename")
if len(FileName)0 then
if CheckForFile(FileName) then
msg="File name already used"
end if
end if
function CheckForFile(pfilename)
'put your code to check for the file here
'let's simulate it finding the file:
CheckForFile=true
end function
%>
<HTML>
<BODY>

<FORM action="" method=post>
<INPUT id=text1 name=filename value=" <%=filename%>">
<span style="FONT-SIZE: large; COLOR: red"><%=msg%>
</span><br>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>

</BODY>
</HTML>
Bob, thanks! I believe I can use this, but first, let me understand, your code assumes
that the form submits to itself, right? So, the page refreshes after submission?


May 9 '07 #3
Bill wrote:
"Bob Barrows [MVP]" wrote...
>Bill wrote:

<FORM action="" method=post>
Bob, thanks! I believe I can use this, but first, let me understand,
your code assumes that the form submits to itself, right? So, the
page refreshes after submission?
Correct. Leaving the action attribute empty causes it to submit to itself
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
May 9 '07 #4
Bill wrote on Wed, 9 May 2007 12:15:29 -0400:
"Bob Barrows [MVP]" wrote...
>Bill wrote:
>>I'm building a simple file management application using Classic ASP
VBScript that has a form to input page content, and file name.

After the form is submitted, the application will check to see if a
page with that file name already exists - if the file name already
exists the user is quickly notified and asked to provide a different
file name for that page.

What I would like to do is, when the user submits the form, if the
file name already exists, stay on the form page (instead of changing
to another page) and just have some red letters next to the file name
say "file name already in use".

Can anyone tell me how to do this???
Like this?

<%
dim FileName, msg
FileName=Request.Form("filename")
if len(FileName)0 then
if CheckForFile(FileName) then
msg="File name already used"
end if
end if
function CheckForFile(pfilename)
'put your code to check for the file here
'let's simulate it finding the file:
CheckForFile=true
end function
%>
<HTML>
<BODY>

<FORM action="" method=post>
<INPUT id=text1 name=filename value=" <%=filename%>">
<span style="FONT-SIZE: large; COLOR: red"><%=msg%>
</span><br>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>

</BODY>
</HTML>

Bob, thanks! I believe I can use this, but first, let me understand, your
code assumes that the form submits to itself, right? So, the page
refreshes after submission?
Yes, that's the way to do it without using something like AJAX. It's simple
to code, and all work is done server side.

Dan
May 9 '07 #5
Gazing into my crystal ball I observed "Bob Barrows [MVP]" <reb01501
@NOyahoo.SPAMcomwriting in news:O7**************@TK2MSFTNGP05.phx.gbl:
><FORM action="" method=post>
<INPUT id=text1 name=filename value=" <%=filename%>">
<span style="FONT-SIZE: large; COLOR: red"><%=msg%>
</span><br>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>
Better because it gives the user other visual clues - you would want to
use Strong because it should give an audible indication to a speaking
browser:
<% if len(FileName)0 then
if CheckForFile(FileName) then
message="File name already used"
required = "text1"
end if
end if
if message <"" then
message = "<div class='message'><strong>" & message & "</strong>
</div>"
"<script type='text/javascript'>alert " & message & ";</script>"
end if
%>
<style type="text/css">
..message {color:red; background-color:transparent; font-weight:bold;}
<% if required <"" then%>
#<%=required%>1 {background-color:yellow; color:#000}
#<%=required%{background-color:pink; color:#000}
<% end if%>
</style>
</head>
<body>
<form method="post" action="">
<%=message%>
<label for="text1" id="text11">Text</label>
<input type="text" name="text1" id="text1" value="<%=filename%>">
<input type="submit" value="Submit">
</form>
</body>
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

May 10 '07 #6
"Daniel Crichton" wrote...
:
Yes, that's the way to do it without using something like AJAX. It's simple
to code, and all work is done server side.

Dan
Ah, your comment led me to find XMLHttpRequest!

A bit of JavaScript, and I'll teach myself how to do this with XMLHttpRequest - seems a
good function to add to my toolbox.

Thanks all,

Bill.


May 12 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Lars Plessmann | last post by:
Problem: I try to store data in a objects field and read it out again. Sounds easy, yeah. But its a bit tricky here.... ;-) This is the class Customer.php with some setter and getter functions...
1
by: Tim | last post by:
Hello, I'm extremely puzzled; I cannot figure out what I'm doing wrong. Here's the situation. I would really appreciate any suggestions. I'm modifying a shopping cart in the following way....
3
by: Andy | last post by:
Hi, I am complete JavaScript novice and would really appreciate some help with this code: ===================================================================== <%@LANGUAGE="VBSCRIPT"...
4
by: joebob | last post by:
The following script if run in Internet Explorer should display a thumbview of a webpage that you point it to. To test it, replace test.htm with a valid html file. The problem I'm having is that...
13
by: Steve Jorgensen | last post by:
== On Error Resume next, and Err.Number == If you want to call one of your procedures from another procedure, and check for errors afterward, you mayimagine that you should write code something...
2
by: Tim Gallivan | last post by:
Hi group, I'm having a strange problem with event handling. My project has a form with a textbox that creates 25 instances of class A when a button is clicked. Class A raises the event without...
2
by: pruebauno | last post by:
I am currently working on a tricky problem at work. I googled around a bit, but "time intervals" did not come up with anything useful. Although I have some rough idea of how I could solve it, I...
7
by: wraithzshadow | last post by:
hello, I'm trying to code a form that will output all data on from one table into separate pages (can scroll through them using the arrows, or entering a specific entry at the bottom), but on each...
9
by: raylopez99 | last post by:
Just an observation: pens for drawing lines in Win Forms are tricky when assignment is inside the paint handler. inside of the Paint handler, but not inside a "using" brace (that is, outside of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.