473,888 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript confirm delete

I have an html form with a number of checkboxes that can be checked
to delete
items. I want to have a javascript alert prompt box to pop up to
confirm the delete.
I am building my site with javascript as an enhancement and not a
to work.
My question is can I have the html form function normally if the user
has javascript
disabled? It would act as thought there were no javascript code
involved in the
form at all then.

Jul 23 '05 #1
2 10125
On Mon, 01 Nov 2004 22:53:57 -0600, neoconwannabe wrote:
I have an html form with a number of checkboxes that can be checked
to delete
items. I want to have a javascript alert prompt box to pop up to
confirm the delete. ... My question is can I have the html form function normally if the user
has javascript disabled?

YEs, by dumping the idea of the pop-up (Won't work on
the 'real world' wide web) and using a second HTML page
instead "You selected the following items for deletion, click
'OK' to proceed, else 'Cancel' to resume without delete"

Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #2
neoconwannabe wrote:
Hi, [...] My question is can I have the html form function normally if the user
has javascript
disabled? It would act as thought there were no javascript code
involved in the
form at all then.


My reading was that you wanted the delete confirmed if JS was enabled,
but if it wasn't, the form just submits. Here is a script that
confirms when a user checks a box, but doesn't confirm when they
uncheck it. If they cancel the delete action, the box is unchecked.

When the form is submitted, if JS is enabled, the hidden checkbox js is
checked so you know at the server that they have already confirmed the
delete. If they don't have JS enabled, then you know they haven't been
given the prompt because the JS checkbox will not be checked.

I've used a label so you can click on the label text or the checkbox to
check/uncheck it.

Be careful with the reference to the label text. If you put the text
before the checkbox, then "a.nextSibl ing" will be undefined and an
error will result. You may want to use
"a.parentNode.c hildNodes[0].data" if the text is before the checkbox,
or "a.parentNode.c hildNodes[1].data" if you put the text after the
checkbox. I just like nextSibling because it's more concise but you
must put the label text after the checkbox.

*However*, as Andrew advises, if this is for a web site, the confirm
prompt is a bad idea and you should use a summary page to confirm what
the user wants. Yes, it's more laborious, but much more reliable and
if there are a lot of options, they all get confirmed in one go rather
than lots of separate confirms. Consider whether some other method of
confirmation is suitable, like such as a visual prompt in the page
(change the text label to grey or use strike-through or similar).

Cheers, Rob.

<script type="text/javascript">
function doIt(a) {
var b = (confirm('This will delete ' + a.nextSibling.d ata
+ '\nClick \'OK\' to confirm'));

// Do the delete actions
} else {
a.checked=false ;
<p>Click on a checkbox to delte the option</p>
<form action="">
<input type="checkbox" name="js" style="display: none;">
<label><input type="checkbox" name="opt1"
onclick="if(thi s.checked)doIt( this);">Option 1</label><br>
<label>Option 2<input type="checkbox" name="opt2"
onclick="if(thi s.checked)doIt( this);"></label><br>
<input type="reset">
<input type="submit" onclick="this.f orm.js.checked= true">
Jul 23 '05 #3

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

Similar topics

by: Jeremy | last post by:
I have a datagrid that users interact with to add/edit/delete, but before the .aspx submits for the delete action I want to pop up a JavaScript confirm box. If the user clicks OK on that box I want the page to be submited and to delete the item(s) from the grid, if the user clicks CANCEL I don't want the page to do a postback. So far I have everything working except the JavaScript confirm box (in other words the delete just happens
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when they press "Cancel" they call another ASPX function. My code now is: System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf) System.Web.HttpContext.Current.Response.Write("if (confirm('Are you sure you want to...
by: JWM | last post by:
Hello: Here is what I am trying to do...... The user clicks on the delete icon, and gets a JavaScript client-side popup to confirm that he wants to delete. I am passing this client-side function a contactID. Then, I want to send the result of this confirm (true|false) to a server-side VBScript function, along with the contactID. The VBScript function will then perform a delete in the database for the specified contactID.
by: Muhammad Abdullah | last post by:
Hi am having some problems with the javascript confirm. i have it working fine on one page and it doesnt even pop up at the other. The code on the working page is, private void Page_Load(object sender, System.EventArgs e) { if(! Page.IsPostBack)
by: mark | last post by:
im having issues in creating a javascript confirm option on pressing a delete button in a datagrid - ive tried a few things but nothing seems to work (either crashes or does nothing) my codebehind is laid out like this :- Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand 'edit from datagrid
by: Jim Heavey | last post by:
Hello, hopefully this is a simple question.. I have the following statemen <asp:Button ID="cmdPPIPDelete" Text="Delete" Runat="server" CssClass="buttonDelete" CommandName="Delete" OnClick="return confirm('Please Confirm You Want To Delete Record')"></asp:Button Each time I navigate to this page, I get a compile error of "CS1041 Identifier expected, return is a keyword" Iif I take out the javascript, then I have no errors when I...
by: TJS | last post by:
javascript "confirm" fires after deletion instead of before deletion. how do I get this to stop the processing ? code ================== Sub ShowAlert(ByVal s As string) RegisterClientScriptBlock("CSP-showconfirm-function", _ "<s"+"cript language=""JavaScript"">" & vbCrLf & _
by: tfsmag | last post by:
Okay, I have a project management app i'm writing and in the left hand menu i have a treeview control that is populated with each project... in child nodes under each project node I have an "edit" and a "delete" node. I have the functionality of the edit and delete working fine, my issue is now however that I cannot seem to find a way to add an "onclick" event that fires a confirm box. I've tried this method.. treenode.Text = "<a...
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you get response from a Confirm() popup window to uncheck all server-side checkboxes placed in a panle of a web user control? I am using ASP.Net 2.0, Thanks. Need info...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.