Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 28th, 2004, 09:57 PM
Registered User
 
Join Date: Aug 2004
Location: Mississauga, Ontario, Canada.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTML Confirm

I am new to HTML and am looking for help on coding the IHTMLWindow2::confirm Method, so that I can display a message and check whether the user clicked on "OK" or "Cancel". Could you provide a simple example please?


Reply With Quote
  #2 (permalink)  
Old August 29th, 2004, 03:47 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well inside a web page it's trivial, window is the global object so you can just write the following in a script block:
Code:
var bContinue = confirm("Do you wish to continue?");  //OR window.confirm(...
alert(bContinue);  //OR window.alert(....
If you are manipulating IE via automationthen you need (from a stand alone javascript:
Code:
var oIE = new ActiveXObject("InternetExplorer.Application");
oIE.navigate("about:blank");
while (oIE.readyState != 4)
{
  WScript.sleep(200);
}
oIE.visible = true;
var oWin = oIE.document.parentWindow;
var bContinue = oWin.confirm("Do you wish to continue?");
WScript.echo("Continue: " + bContinue);
--

Joe
Reply With Quote
  #3 (permalink)  
Old August 29th, 2004, 09:40 AM
Registered User
 
Join Date: Aug 2004
Location: Mississauga, Ontario, Canada.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I thought it was simple, but it must be the way I am embedding my code or .... Here is a snippet of the code in my HTML:
    <% else if Session("Success") = "D" then
        Session("Success")=""
        %>
            var dRequest = confirm('Thank You. Your input has been recorded. Do you wish to record a Donation at this time?', *Donationrequest);
        <% if dRequest = True then %>
                window.location.href = '/donations/default.aspx&App=DONATIONS&ItemNo=1&nid=<%=session ("UserID")%>&hid= <%=session("Hierarchy")'
        <% else if Session("Mode") = "Add" then %>
                window.location.href = 'ViewEditGrid.aspx?mode=SubmitActuals&nid=<%=sessi on("UserID")%>&hid= <%=session("Hierarchy")'
        <% else if Session("Mode") = "Edit" then %>
                            window.location.href = 'ViewEditGrid.aspx?mode=Actual&nid=<%=session("Use rID")%>&hid= <%=session("Hierarchy")'
        <% else %>
                            window.location.href = '/Fraternal/BranchesAndRegions/Default.aspx'
        <% end if %>


The error I am getting is:
Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322.573
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.

c:\inetpub\wwwroot\Events\SubmitActualEvent.aspx(4 28) : error BC30451: Name 'dRequest' is not declared.

                if dRequest = True then
                   ~~~~~~~~


Reply With Quote
  #4 (permalink)  
Old August 30th, 2004, 10:36 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

That's because you are mixing server side code and client side code. Code between <% %> tags is executed on the server, code in <script blocks on the client. You can only send data from client to server via an HTTP request, either GET or POST.

--

Joe
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Confirm in ItemDataBound rstelma ASP.NET 1.0 and 1.1 Basics 3 December 6th, 2006 02:10 AM
Confirm messagebox edwin.debrouwere ASP.NET 2.0 Basics 0 September 5th, 2006 07:29 AM
confirm crmpicco Javascript How-To 2 February 7th, 2005 01:23 PM



All times are GMT -4. The time now is 02:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.