469,336 Members | 5,286 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

Javascript Yes/No

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
Jul 19 '05 #1
12 8860
Fawke101 wrote:
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.


--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 19 '05 #2
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
"Randy Webb" <hi************@aol.com> wrote in message
news:kv********************@comcast.com...
Fawke101 wrote:
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.


--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 19 '05 #3
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")
Jul 19 '05 #4
<a href="remove.asp?ID=<% =server.URLEncode(RS("ID"))%>"
onClick="confirm('Are you sure?');">Remove</a>

It's not really an ASP question.

"Fawke101" <gu*@ANTIbradflack.SPAMcom> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
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

Jul 19 '05 #5
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
"Saint Jude" <th**************@hotmail.com> wrote in message
news:e7****************@TK2MSFTNGP09.phx.gbl...
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")

Jul 19 '05 #6
Fawke101 wrote:
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.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 19 '05 #7
Perfect! Big Thanks!

--
Thanks in advance

Fawke

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

www.bradflack.com
"TomB" <sh*****@hotmailXXX.com> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
<a href="remove.asp?ID=<% =server.URLEncode(RS("ID"))%>"
onClick="confirm('Are you sure?');">Remove</a>

It's not really an ASP question.

"Fawke101" <gu*@ANTIbradflack.SPAMcom> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
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


Jul 19 '05 #8
TomB wrote:
<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.
Jul 19 '05 #9
Dave Anderson wrote:
TomB wrote:
<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?')"...
^^^^^^^


Yes, it should be. Otherwise its pointless to have it.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 19 '05 #10
Oops

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:ei*************@TK2MSFTNGP10.phx.gbl...
TomB wrote:
<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.

Jul 19 '05 #11

I don't get it to work, it transfers me right away to the url, an
doesn't display a confirm window at all.
TomB wrote:
*Oops

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:ei*************@TK2MSFTNGP10.phx.gbl...
TomB wrote:

Shouldn't that be this?

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

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 pe

message.
Use
of this email address implies consent to these terms. Please d

not
contact
me directly or ask me to contact you directly for assistance. I

your
question is worth asking, it's worth posting.

-
matt
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------

Jul 19 '05 #12
mattm wrote:

Shouldn't that be this?

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

...


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.
Jul 19 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.