WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-24-2008, 07:11 PM
WebProWorld New Member
 

Join Date: Dec 2007
Posts: 7
Beta_Grumm RepRank 0
Default Trouble with javascript confirm() and IE...

Hi.

First off I would like to say how much I love these forums, and find them very informative.

Ok, straight to the problem:

THE SCRIPT:
function check_for_save()
{
check = confirm("message");

if (check)
{ return true; }
else
{ return false; }
}


THE LINK
<a href="GearBag.asp?id=<%=id%>" style="text-decoration:none"><input <%=disabled%> type="button" value="Add/Edit Gear" onClick="return check_for_save()" /></a>

The confirm works correctly
in both browsers returning "true" or "false" depending on what button is pushed, but IE will not follow through with the link. It just stays on the same page.
I have tried sever different styles of code, and from what I see, the fact that I am using a button is causing the problem. But I need the button.

I'm just wondering if any has dealt with this before? Or could possibly suggest a good resource on the subject.

Thanks,
Micah

Reply With Quote
  #2 (permalink)  
Old 01-24-2008, 08:09 PM
DaveSawers's Avatar
WebProWorld Veteran
 

Join Date: Dec 2006
Location: Calgary, Alberta, Canada
Posts: 385
DaveSawers RepRank 1
Default Re: Trouble with javascript confirm() and IE...

Good old IE! The way you're trying to do it isn't exactly standard.

You could put a form around the button, set the link as the action and set the button up to run the check_for_save function. If it returns true, run the Javascript submit function to submit the form.

Something like:

Code:
<script type="text/JavaScript">
<!--
function check_for_save()
{
	check = confirm("message");

	if (check)
		{ document.forms[0].submit(); }
}
//-->
</script>

...

<form id="form1" name="form1" method="post" action="GearBag.asp">
  <input name="Button" type="button" onclick="javascript:check_for_save()" value="Button" />
</form>
__________________
Dynamic Software Development
www.activeminds.ca
Reply With Quote
  #3 (permalink)  
Old 01-25-2008, 11:20 AM
WebProWorld New Member
 

Join Date: Dec 2007
Posts: 7
Beta_Grumm RepRank 0
Default Re: Trouble with javascript confirm() and IE...

Thanks for the reply.

I have considered this application, but the button is currently in the middle of another form. And forms don't like to be inside of another form.
Worst case scenario I may just have to move all the buttons out side of the form. (There are actually three buttons all with different links)
However for now, the user likes the payout the way it is.

One thing that I tried last night and work as a link on both browsers:

SCRIPT
<SCRIPT LANGUAGE="javascript">
<!---
function ConfirmLink(url){
if(confirm('Are you Sure?')) location.href = url;
}

LINK
<a href="javascript:ConfirmLink('http://www.nrsweb.com/');">Home Page</a>

But when I change it to a button:
<a href="javascript:ConfirmLink('http://www.nrsweb.com/');"><input type="button" value="Home Page" /></a>

FireFox called the confirm function twice and IE didn't do anything at all.
There has to be a way to make this work. I'm just running out of resources.

Thanks again.
Reply With Quote
  #4 (permalink)  
Old 01-25-2008, 11:37 AM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,784
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: Trouble with javascript confirm() and IE...

What if you changed:

<a href="javascript:ConfirmLink('http://www.nrsweb.com/');"><input type="button" value="Home Page" /></a>

to:

<input type="button" value="Home Page" onClick="ConfirmLink('http://www.nrsweb.com/'); />

Since the <a> tag now has a javascript, you no longer get any benefit to having a link at all, so this should cause everything to be handled from the button itself.
__________________
The best way to learn anything, is to question everything.

Last edited by wige : 01-25-2008 at 11:38 AM. Reason: oops
Reply With Quote
  #5 (permalink)  
Old 01-25-2008, 01:31 PM
WebProWorld New Member
 

Join Date: Dec 2007
Posts: 7
Beta_Grumm RepRank 0
Default Re: Trouble with javascript confirm() and IE...

Nicely done. That did the trick.

Thanks guys for your help.

Micah
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum


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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I do a re-confirm your subscription process? Weedy Lady Marketing Strategies Discussion Forum 6 07-22-2006 04:31 PM
Ask Jeeves Advertisers Confirm "Premier Listings" Replaceme WPW_Feedbot Search Engine Optimization Forum 0 07-28-2005 10:00 AM
IM threats rising sharply, reports confirm WPW_Feedbot IT Discussion Forum 0 04-05-2005 02:00 PM
Trouble with javascript-mouseover markb1 Graphics & Design Discussion Forum 6 09-08-2004 04:29 AM
Need confirm password help dchuke Web Programming Discussion Forum 4 06-22-2004 09:47 AM


Search Engine Optimization by vBSEO 3.2.0