Tricky Form Problem
am 09.05.2007 17:33:04 von bill
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.
Re: Tricky Form Problem
am 09.05.2007 18:02:51 von reb01501
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
%>
--
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"
Re: Tricky Form Problem
am 09.05.2007 18:15:29 von bill
"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
> %>
>
>
>
>
>
>
>
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?
Re: Tricky Form Problem
am 09.05.2007 18:25:47 von reb01501
Bill wrote:
> "Bob Barrows [MVP]" wrote...
>> Bill wrote:
>>
>>
Re: Tricky Form Problem
am 09.05.2007 18:30:17 von Daniel Crichton
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
>> %>
>>
>>
>>
>>
>>
>>
>>
>
> 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
Re: Tricky Form Problem
am 10.05.2007 10:08:12 von Adrienne Boswell
Gazing into my crystal ball I observed "Bob Barrows [MVP]"
@NOyahoo.SPAMcom> writing in news:O7pE7NlkHHA.4900@TK2MSFTNGP05.phx.gbl:
>
>
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 = "" & message & "
"
""
end if
%>
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Re: Tricky Form Problem
am 12.05.2007 17:48:57 von bill
"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.