Javascript Yes/No

F

Fawke101

Hi there,

I have searched for some examples, but to no real avail, for a JS function
that displays a user Yes/No dialog box.
Basically, i have an ASP application that displays a SQL table on an ASP
page.

I have created a "Remove" hyperlink (in a loop) by each record and i need to
use an OnClick event so when the user clicks this hyperlink it displays this
Yes/No dialog.
At the moment the hyperlink simply removes the relevant record.

I need an OnClick event that displays a Yes/No box that when the user clicks
Yes - it goes to remove.asp, and when No is clicked it does nothing.

User Clicks Remove next to record > Yes/No dialog> Yes = remove.asp No =
End.

*****
*****
Current Hyperlink (passing ID variable in querystring - needs to be
maintained through the JavaScript:

<a href="remove.asp?ID=<% =server.URLEncode(RS("ID"))%>">Remove</a>
*****
*****

Any code/help would be much appreciated.
Thanks

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
 
R

Randy Webb

Fawke101 said:
Hi there,

I have searched for some examples, but to no real avail, for a JS function
that displays a user Yes/No dialog box.
Basically, i have an ASP application that displays a SQL table on an ASP
page.

I have created a "Remove" hyperlink (in a loop) by each record and i need to
use an OnClick event so when the user clicks this hyperlink it displays this
Yes/No dialog.
At the moment the hyperlink simply removes the relevant record.

I need an OnClick event that displays a Yes/No box that when the user clicks
Yes - it goes to remove.asp, and when No is clicked it does nothing.

User Clicks Remove next to record > Yes/No dialog> Yes = remove.asp No =
End.

*****
*****
Current Hyperlink (passing ID variable in querystring - needs to be
maintained through the JavaScript:

<a href="remove.asp?ID=<% =server.URLEncode(RS("ID"))%>">Remove</a>
*****
*****

<a href="#" onclick="customConfirm('remove.asp?ID=<%
=server.URLEncode(RS("ID"))%>');return false">Remove</a>

customConfirm would be a function that accepts the URL as a parameter,
then shows a DIV in the center of the screen with two buttons. The
buttons would have onclicks that when clicked, would either do nothing
(the NO button) or set location.href to the remove.asp page.
 
F

Fawke101

Thanks for your prompt reply......
Sorry to be a pain, i am no JS developer, Any examples of this?

Thanks so much


--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
 
S

Saint Jude

Would a confirm dialog be OK ?
You can't chnage the button text, but the meaning is clear.

if(confirm("You want this ?"))
alert("yes")
else
alert("No")
 
T

TomB

<a href="remove.asp?ID=<% =server.URLEncode(RS("ID"))%>"
onClick="confirm('Are you sure?');">Remove</a>

It's not really an ASP question.
 
F

Fawke101

A confirm would be fine.......

I just wouldnt mind knowing how to incorporate this into my ASP -

Do you want this?
Yes -goto remove.asp
No - -*nothing*

How can i incorporate this JS into my code (sorry, i am not clued up with
JS at all)

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
 
R

Randy Webb

Fawke101 said:
A confirm would be fine.......

I just wouldnt mind knowing how to incorporate this into my ASP -

Do you want this?
Yes -goto remove.asp
No - -*nothing*

How can i incorporate this JS into my code (sorry, i am not clued up with
JS at all)

<a href="URL" onclick="return confirm('Are you sure you want to remove
this item?')">Remove</a>

If they click OK, it returns True and the link is navigated to. If they
click cancel, the confirm returns false and the href is not followed.
 
D

Dave Anderson

TomB said:
<a href="remove.asp?ID=<% =server.URLEncode(RS("ID"))%>"
onClick="confirm('Are you sure?');">Remove</a>

It's not really an ASP question.

Shouldn't that be this?

...onclick="return confirm('Are you sure?')"...
^^^^^^^



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
T

TomB

Oops

Dave Anderson said:
Shouldn't that be this?

...onclick="return confirm('Are you sure?')"...
^^^^^^^



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
D

Dave Anderson

mattm said:
I don't get it to work, it transfers me right away to the url,
and doesn't display a confirm window at all.

That's the point of returning a value -- to avoid the very problem you are
experiencing. Please review the above carefully.

If you would like something a bit more enlightening than formulaic, try the
following:

<A HREF="" ONCLICK="return false">Click here</A>

Observe its behavior. Now modify it slightly:

<A HREF="" ONCLICK="confirm('Really?');return false">Click here</A>

Again, observe the behavior. Last of all, go back to the structure of my
original suggestion, and see what it does:

<A HREF="" ONCLICK="return confirm('Really?')">Click here</A>

Now you should understand what you are doing wrong.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top