★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum3/HTML/000490.htmlNouvelle recherche | Portail wanayoo
DevShed Menu
* DevShed Home
* Developer News
* DevShed Brain Dump




UBBFriend: Email This Page to Someone!
  DevShed Discussion Forums
  JavaScript
  Check and uncheck checkboxes

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Check and uncheck checkboxes
peterbe
Member
posted July 28, 2000 05:55 AM     Click Here to See the Profile for peterbe   Click Here to Email peterbe     Edit/Delete Message Reply w/Quote
I want that - when people tick a checkbox for Delete in a form - that a confirm screen pops up to verify their choice.
I begin by testing with confirm() and if it's 'true' then check the box they chose.
If not true, then uncheck the box they chose.

How do you UNcheck a checkbox box?

Code:

code:
<script language="JavaScript">
<!--
function Delmsg(productID,product_description,fieldname) {
var msg;
msg = "---------------------------------------- Caution message --------------------------------------------\n\n\n";
msg += "Are you sure you want to delete this one?\n\nproductID:\t\t ";
msg += productID;
msg += "\nproduct_description:\t";
msg += product_description;
msg += "\n\n\n---------------------------------------- Caution message -------------------------------------------\n";

if (confirm(msg)) {
document.change_product.fieldname.checked;
} else {
!document.change_product.fieldname.checked;
}
//alert(msg);
}
-->
</script>

Call:

code:
<input type=checkbox name=delete_0 value="500NO" onClick="javascript elmsg('500NO','Single Computer, 500K','delete_0')">

------------------

¬ peterbe.com ¬

peterbe
Member
posted July 28, 2000 08:40 AM     Click Here to See the Profile for peterbe   Click Here to Email peterbe     Edit/Delete Message Reply w/Quote
Found it!

code:

<script>
var box;
box = eval("document.change_product."+fieldname);

if (box.checked != true) {
box.checked = false;
} else {
if (!confirm(msg)) {
box.checked = false;
}
}</script>

------------------

¬ peterbe.com ¬

All times are MST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | DevShed.com

Copyright © 1997-2000 ngenuity. All rights reserved.

Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.