473,782 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1759
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=Reques t.Form("filenam e")
if len(FileName)0 then
if CheckForFile(Fi leName) then
msg="File name already used"
end if
end if
function CheckForFile(pf ilename)
'put your code to check for the file here
'let's simulate it finding the file:
CheckForFile=tr ue
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=Reques t.Form("filenam e")
if len(FileName)0 then
if CheckForFile(Fi leName) then
msg="File name already used"
end if
end if
function CheckForFile(pf ilename)
'put your code to check for the file here
'let's simulate it finding the file:
CheckForFile=tr ue
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=Reque st.Form("filena me")
if len(FileName)0 then
if CheckForFile(Fi leName) then
msg="File name already used"
end if
end if
function CheckForFile(pf ilename)
'put your code to check for the file here
'let's simulate it finding the file:
CheckForFile=t rue
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.SPAMco mwriting in news:O7******** ******@TK2MSFTN GP05.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(Fi leName) 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'>ale rt " & message & ";</script>"
end if
%>
<style type="text/css">
..message {color:red; background-color:transpare nt; font-weight:bold;}
<% if required <"" then%>
#<%=required%> 1 {background-color:yellow; color:#000}
#<%=required%{b ackground-color:pink; color:#000}
<% end if%>
</style>
</head>
<body>
<form method="post" action="">
<%=message%>
<label for="text1" id="text11">Tex t</label>
<input type="text" name="text1" id="text1" value="<%=filen ame%>">
<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
2163
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 to store customers data within an object. It works. Furthermore, it includes a synchronize method, which calls the individual setXXX function and takes the data from the $_POST or $_GET var.
1
1998
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. I've just added new prices to several drop-downs on our javascript-based ordering page. These new prices must have shipping costs added to them at the bottom of the ordering system in a text box called "Shipping", while the existing prices do not...
3
1844
by: Andy | last post by:
Hi, I am complete JavaScript novice and would really appreciate some help with this code: ===================================================================== <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="Connections/ssdb.asp" -->
4
5888
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 I can't get onclick to fire on the rendered Thumbview object. What's strange is that onmouseover fires. Can anyone see a way? <html><head><title>test</title></head> <body onload="Init()">
13
2761
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 like this... On Error Resuse Next MyFoo 123 lngErrNum = Err.Number On Error Goto 0
2
1334
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 error, I have proved this by having it use a streamwriter to create and write to a simple text file after raising the event. Twenty-five files are created each time the button is pressed. The form is wired up to the event (rr.OnComplete += new...
2
1824
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 still would value some input. I have information of (It has only couple dozen entries.) ServiceNum, DollarCost and a input database table in the form (several GBytes): ClientNumber (CN), BeginDate(BD), EndDate(ED),
7
1305
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 page it will look at the primary key for that table, then look at another table, and wherever it contains a reference to that particular value, create a textbox and output a memo onto... since that was probably vague and confusing i will try to...
9
2360
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 "using { Pen mypen = new Pen(Color.Black, 1)) {}), which I think makes a difference: I find the following assignment does not work: //myPenTest instantiated in the normal constructor, as was baseline,
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10311
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10080
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9942
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8967
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.