Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 11th, 2005, 02:46 PM
steeltrap steeltrap is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 175 steeltrap User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 8 h 36 m 22 sec
Reputation Power: 4
Having trouble with message box answer routing

I'm trying to have a link generate a message box that redirects to one page if the yes button is hit, and another if no is clicked as below:
Code:
<a href=delete2.asp?ID=<%=rs.Fields("ID").Value%> onclick=answer1()> Delete </a>	 
	  
	 <SCRIPT LANGUAGE="VBSCRIPT"> 
	  function answer1()
	  dim answer
	   Answer=MsgBox("Are you sure you want to delete this file?",VBOKcancel)
	   if answer = 1 then 
	   window.location="delete2.asp?ID=<%=rs.Fields("ID").Value%>"
	   else
	   window.location="customize.asp"
	   end if
	   
	  end function
	 
	 </script>
	

With this code as is, when I click on the link, it pops up the message box as it should, but no matter which button I hit, it goes to delete2.asp. I know its using the "a href" link to do this, since I've changed the window.location for answer=1 to other things and it still goes to delete2.asp. How else can I set this up so that the message box is making the determination? -Chris

Reply With Quote
  #2  
Old May 12th, 2005, 08:25 PM
blicci's Avatar
blicci blicci is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Philly
Posts: 351 blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 22 h 8 m 5 sec
Reputation Power: 52
Code:
<a href=NULL onclick="answer1(<%=rs.Fields("ID").Value%>)"> Delete </a> 
<SCRIPT LANGUAGE="VBSCRIPT"> 
 
function answer1(idnum)
 
 
 
IF MsgBox("Are you sure you want to delete this file?",VBOKcancel) = vbOk then 
 
window.location="delete2.asp?ID=" & idNum 
 
else
 
window.location="customize.asp"
 
end if
 
 
 
end function
 
 
 
</script>
 

 

Last edited by blicci : May 12th, 2005 at 08:37 PM.

Reply With Quote
  #3  
Old May 13th, 2005, 06:34 PM
steeltrap steeltrap is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 175 steeltrap User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 8 h 36 m 22 sec
Reputation Power: 4
Somethings not right

Blicci, Thank's for the help. It doesn't seem to work though. It just redirects me to a page "path to the current folder\NULL.htm" I tried quotes on the href too, but that didn't seem to make a difference. Any other ideas? -Chris

Reply With Quote
  #4  
Old May 14th, 2005, 10:01 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 32 m 23 sec
Reputation Power: 180
If you get no answer here try the asp forum.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #5  
Old May 15th, 2005, 03:52 PM
blicci's Avatar
blicci blicci is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Philly
Posts: 351 blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 22 h 8 m 5 sec
Reputation Power: 52
try it with a div element instead of a hyperlink.
Also check to see if <%=rs.Fields("ID").Value%> is actually being generated by looking at the source after the page loads.
Code:
<DIV style="cursor:HAND; color:BLUE; text-decoration:underline;" onclick="answer1(<%=rs.Fields("ID").Value%)"> Delete </DIV> 
 
<SCRIPT LANGUAGE="VBSCRIPT"> 
function answer1(idnum)
	if MsgBox("Are you sure you want to delete this file?",VBOKcancel) = vbOk then 
	window.location="delete2.asp?ID=" & idNum 
	else
	window.location="customize.asp"
	end if
 
end function
 
</script>

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Having trouble with message box answer routing


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway