Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InputBox problem

Status
Not open for further replies.

da644

Programmer
May 21, 2001
159
GB
Hi Everyone.

I've created some vbscript that allows the user to input comments before they continue. The code is as follows...

Function ConfirmAuth(pageID)
Dim Comments,Msg,Title,theLocation
Msg = "Please enter any comments in the field below and click OK to submit this page for authorisation, otherwise click Cancel."
Title = "Submit for Authorisation"
Comments = InputBox(Msg,Title)
theLocation = "authorise.cfm?pageID=" & pageID & ""&comments="" & Comments
If Comments > "" Then location.replace(theLocation)
End Function

This work ok, but if the user doesn't enter a comment it doesn't do the location.replace part. I added the If statement so that if they clicked the cancel button it work not do the location.replace. As not entering anything in the text box and pressing cancel return the same, "", is there another way to detect which button, ok or cancel, the user pressed.

Thanks.

Andrew.
 

Try using WshShell popup method

return values can be checked ie:

Set wsh = Wscript.CreateObject("Wscript.Shell")
retval = wsh.popup(msg,,title,1) the 1 = button type 1= OK and Cancel
If cancel is pressed retval = 2
If ok is pressed retval = 1

Steve
Regards
Steve Friday
 
Sorry, that will not help - really must read everything, you need input.

Sorry
Regards
Steve Friday
 
OK so now I'm playing

On Error resume Next
Dim wsh
Set wsh = Wscript.CreateObject("Wscript.Shell")
Msg = "test"
title = "test2"
retval = wsh.popup(Inputbox(msg,title),,"If you wish to quit this programme, click cancel again",1)
if err.number <> &quot;0&quot; Then
Msgbox &quot; No comments entered&quot;
Else
If retval = &quot;2&quot; then
Msgbox &quot;Quiting&quot;
Wscript.Quit
Else
msgbox &quot;Continue Processing &quot;
End If
End If


Steve
I'm sure there is a better way but what the hell
Regards
Steve Friday
 
No... that doesn't work... it always goes via the Msgbox &quot;No comments entered&quot; statement... whether a comment is enter or not or cancel is clicked...

But thanks for trying... Any other ideas????
 
Your right, biggest load of rubbish I have ever done, the thing that bothers me is that it worked when I was at work but now it is C**p will test again tomorrow
Regards
Steve Friday
 
Unfortunately not. Leaving the textbox empty and clicking OK is equivalent to clicking Cancel.

You could add a disclaimer to the user.

Msg = &quot;Please enter any comments in the field below and click OK to submit this page for authorisation, otherwise click Cancel.&quot; & vbcrlf & &quot;Omitting a comment will cancel the operation. Please enter None if wish to submit without a comment.&quot;

Or you could place a default in the inputbox.

Comments = InputBox(Msg,Title,&quot;None&quot;)

But neither solution is perfect. Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top