|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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
|
|
#4
|
|||
|
|||
|
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 |
|
#5
|
||||
|
||||
|
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>
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Having trouble with message box answer routing |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|