Action From An Alert Box

S

Slartybartfast

I have a link that when clicked does something on another machine, and it
all works fine.
<a href=http://www.remotedomain.com/cgi-bin/task.cgi?identifier>Do That
Thing</a>

But I thought it might be a good idea to verify the user is wants to do it
(and didn't click on the link by accident), so I added the following
javascript:


<script language="JavaScript">
function doit() {
if(confirm('Do you really want to do that thing?'))
{ decision.value =
'http://www.remotedomain.com/cgi-bin/task.cgi?identifier;' submit(); }
}

</script>



<a href="javascript:doit()">Do That Thing</a>

The alert box pops up fine, but I've tried a bunch of different things and I
can't get the link to work when the user clicks on the OK button.

Can someone please give me an idea what's wrong?
 
C

Charles Banas

i'll try preempting the experts and see how i fare. :)

I have a link that when clicked does something on another machine, and it
all works fine.
<a href=http://www.remotedomain.com/cgi-bin/task.cgi?identifier>Do That
Thing</a>

But I thought it might be a good idea to verify the user is wants to do
it
(and didn't click on the link by accident), so I added the following
javascript:


<script language="JavaScript">
function doit() {
if(confirm('Do you really want to do that thing?'))
{ decision.value =
'http://www.remotedomain.com/cgi-bin/task.cgi?identifier;' submit(); }
}

</script>



<a href="javascript:doit()">Do That Thing</a>

The alert box pops up fine, but I've tried a bunch of different things
and I
can't get the link to work when the user clicks on the OK button.

Can someone please give me an idea what's wrong?
try doing it this way:

<a href="http://www.remotedomain.com/cgi-bin/task.cgi?identifier"
onclick="confirm('Do you really want to do that thing?');">Do That
Thing</a>

since confirm() returns true or false, true will allow the link to continue
and false will abort it.

now. let's see what i did wrong. i know i missed something. :)
 
R

Richard Cornford

<a href="http://www.remotedomain.com/cgi-bin/task.cgi?identifier"
onclick="confirm('Do you really want to do that thing?');">Do
That Thing</a>

since confirm() returns true or false, true will allow the link to
continue and false will abort it.

now. let's see what i did wrong. i know i missed something. :)

You forgot to return a value from the onclick handler. With out a return
value the navigation will not be cancelled:-

onclick="return confirm('Do . . . thing?');"

Richard.
 
C

Charles Banas

The experts would add a "return" in front of the call to "confirm" :)

... onclick="return confirm(...)"
pah. i knew it. i always forget something. :)
To know what it is that you do not know, is a kind of omniscience.
/L

too bad i'm not God, eh.
 
S

Slartybartfast

Thank you guys. It works like a charm.

As for the POST vs. Get; it makes sense. I'm looking into it. Thanks. I
 

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

Forum statistics

Threads
474,082
Messages
2,570,587
Members
47,209
Latest member
Ingeborg61

Latest Threads

Top