473,385 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Action From An Alert Box

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?

Jul 20 '05 #1
5 6035
i'll try preempting the experts and see how i fare. :)

On Wed, 27 Aug 2003 18:08:13 GMT, Slartybartfast <we********@hotmail.com>
wrote:
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. :)

--
Charles Banas
Jul 20 '05 #2
"Charles Banas" <no****@myplace.net> wrote in message
news:op**************@news.cableone.net...
<snip>
<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.
Jul 20 '05 #3
On 27 Aug 2003 20:55:30 +0200, Lasse Reichstein Nielsen <lr*@hotpop.com>
wrote:
The experts would add a "return" in front of the call to "confirm" :)

... onclick="return confirm(...)"

pah. i knew it. i always forget something. :)
now. let's see what i did wrong. i know i missed something. :)


To know what it is that you do not know, is a kind of omniscience.
/L


too bad i'm not God, eh.

--
Charles Banas
Jul 20 '05 #4
Slartybartfast wrote:
I have a link that when clicked does something on another machine,
GET methods are supposed to be "safe". They are not meant to change state
on a server.

<URL:http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1>
<URL:http://www.cs.tut.fi/~jkorpela/forms/methods.html>

Have you considered using a form with POST?

and it all works fine.
<a href=http://www.remotedomain.com/cgi-bin/task.cgi?identifier>Do That
Thing</a>
For some value of "works fine". It's incorrect HTML and can cause problems:

<URL:http://www.cs.tut.fi/~jkorpela/qattr.html>

Also, somebody owns remotedomain.com - example.com has been reserved for
examples of this nature.

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 =
What does 'decision' refer to?

'http://www.remotedomain.com/cgi-bin/task.cgi?identifier;' submit(); }
What does 'submit()' refer to? And don't you want the preceding ;' to be
';?
[snip] <a href="javascript:doit()">Do That Thing</a>
The FAQ explains why this is a bad idea:

<URL:http://jibbering.com/faq/#FAQ4_24>

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.


You want something like this:

<form action="http://www.example.com/cgi-bin/task.cgi?identifier"
method="post" onsubmit="return confirm('Are you sure?');">
<input type="submit" value="Do that thing">
</form>

If you are concerned about the fact that you have a button instead of a
link, please read this:

<URL:http://tom.me.uk/scripting/submit.asp>
--
Jim Dabell

Jul 20 '05 #5
Thank you guys. It works like a charm.

As for the POST vs. Get; it makes sense. I'm looking into it. Thanks. I
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: TJS | last post by:
what is wrong here, the submit will only post page back to itself instead of specifed action <SCRIPT language="Javascript"> function Submit_Form(){ document.Form1.Action="cart.asp";...
17
by: abs | last post by:
My element: <span onclick="alert('test')" id="mySpan">test</span> Let's say that I don't know what is in this span's onclick event. Is it possible to add another action to this element's onclick...
10
by: iam247 | last post by:
Hi In my prototype asp page (with no javascript and no password validation, I have a registration form with the following action: <form name="form" method="post" action="RegDetails.asp"> ...
2
by: iam247 | last post by:
Hi In my prototype asp page (with no javascript and no password validation, I have a registration form with the following action: <form name="form" method="post" action="RegDetails.asp"> ...
0
by: nycjay | last post by:
i am trying to use the db2 health monitor alert to run a script. i set up the health monitor to run a script when the tablespace utailization is too high. in the end, the script should send a...
14
by: Ed Jay | last post by:
On a multi-textbox form, linked to an external js, I use onBlur to call: function chkNum(cellname) { var str = document.getElementById(cellname).value.toString(10); if (str < 28 || str > 36)...
9
by: finerrecliner | last post by:
i'm trying to make an action listener that will display an alert box when the user clicks anywhere on the page once, and then go back to normal mouse behavior. i have this: <html><script...
8
by: M.L. | last post by:
Hello. I created a form using JS validation with the form tag as follows: <form name="form1" action="dynaform.php" method="post" onsubmit="return pvg_sub();"> The js validation script sends...
6
by: Stanimir Stamenkov | last post by:
I have a form without a submit button like: <form name="form1" action="" onsubmit="alert('submit ' + this.name);"> <div> <label>Field 1: <input type="text" name="field1"...
9
by: Meendar | last post by:
Hi, Below is my code snippet having only one form, <form> <input type ="radio" name="action" value="xyz" checked>xyz <input type ="radio" name="action" value="zyx">zyx <input type ="radio"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.