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
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 Display Modes
  #1 (permalink)  
Old February 20th, 2004, 05:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default Javascript alert box

Hi there

I have this function set up:

function ConfirmDelete(varURL)
{
    if (confirm("Are you sure you want to delete this Listing?"))
        window.open(varURL, "_top");
}

then further down the page, I need to call the function but I think I've got something wrong but not sure what; here's where I call the function:

<form name="frm_del" method="post" action="onClick=javascript:ConfirmDelete ('delete.asp?ListingsID=<%=rsListings("ListingsID" )%>');">

I think it's something to do with the syntax.

Any help greatly appreciated.

thanks

Adam
Reply With Quote
  #2 (permalink)  
Old February 20th, 2004, 05:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I do not know to much about this stuff, but I think you should use the onSubmit event, and not the action attribute. As it is you have got an event in the action attribute, and that will not work.

Hope it helps

Jacob.
Reply With Quote
  #3 (permalink)  
Old February 20th, 2004, 05:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry! A correction to the above... It is not an event, it is rather an attribute, so you can do something like this...

<FORM ONSUBMIT="alert('something');">

I think ;)

Jacob.
Reply With Quote
  #4 (permalink)  
Old February 20th, 2004, 06:21 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

Do you want to submit the form if user chooses yes or do you wish to open a secondary window or both. If both then change the function to the following and include it in the onsubmit event handler:
Code:
function ConfirmDelete(varURL)
{
    if (confirm("Are you sure you want to delete this Listing?"))
    {
        window.open(varURL, "_top");
        return true;
    }
    return false; 
}
This will prevent submission if they chosse 'Cancel' but your form tag needs modifying. Haow depends on your intensions. If you want the new window to appear with the forms results displayed in it that requires use of the target attribute.

--

Joe
Reply With Quote
  #5 (permalink)  
Old February 20th, 2004, 06:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Great, thanks for your input guys; got there in the end!
Reply With Quote
  #6 (permalink)  
Old March 3rd, 2004, 11:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Hi,

Further to this, I'm getting an error message, 'Page cannot be displayed'.

The reason for this is because after posting the form (after the alert etc), the path that the browser is looking for is

secure/PostagePacking/undefined

I don't know why it's returning undefined but here's my coding:

<script language="javascript" type="text/javascript">
function ConfirmBasePrice(varURL)
{
    if (confirm("Make sure you haven't changed\nthe base level from £1.00!"))
    {
        window.open(varURL, "_top");
        return true;
    }
    return false;
}
</script>

and further down:

<form name="form1" method="post" onSubmit="return ConfirmBasePrice();" action="process_update.asp?id=<%=rsPacking("PPid") %>">

Any help much appreciated.

Adam
Reply With Quote
  #7 (permalink)  
Old March 3rd, 2004, 11:38 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

Can you describe in stages what exactly you want to happen? For instance if they click 'OK' do you want the form to submit and the window to open, or do you want to open the result of the post to the popup window?

--

Joe
Reply With Quote
  #8 (permalink)  
Old March 3rd, 2004, 12:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Hi Joe

Yes, if the user clicks OK on the alert box, then I want the form to submit and the window to open, otherwise, if the user clicks cancel, then I want the page to stay as it is.

As it stands, although I get the error as I described before, the changes that I request from the post are still committed to the database.

thanks

Adam
Reply With Quote
  #9 (permalink)  
Old March 3rd, 2004, 12:17 PM
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

But asking for the new window to open as "_top" meansyou want to replace the cureent frameset, don't you want a popup window?

--

Joe
Reply With Quote
  #10 (permalink)  
Old March 3rd, 2004, 12:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Hi Joe

No I want to replace the current frameset with the same page but with the new values on it.

thanks

Adam
Reply With Quote
Reply


Thread Tools
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
problem in alert box amol_0008 Javascript 1 June 14th, 2007 06:17 AM
personalized Alert Box kanoorani Javascript How-To 1 September 5th, 2005 08:58 AM
Javascript alert error Ed7777 Javascript How-To 5 June 25th, 2004 02:23 PM
Confirm alert box - need help, Please! larry HTML Code Clinic 1 January 25th, 2004 01:07 AM
Security Alert Message box pkgal79 HTML Code Clinic 5 June 12th, 2003 09:20 AM



All times are GMT -4. The time now is 11:19 AM.


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