JavaScript - Delete 'new Obj()' Crashes Ie
The js line...
delete new Obj(); brings my script to a halt in IE7. the error in the MS-VWD debugger is... "Cannot delete 'new rect()". The same line seems to work fine in FF. If I change the code to... var o = new Obj(); delete o; - all works fine in IE. Can someone explain why this occurs? btw... the actual code is something like... delete new rect().getElem(elem).hcenterInRect(parRect).setElem(elem); so there's a bunch of processing between the new and deleting of the object ("rect"). this is obviously not a big problem but i was just curious as to how IE was interpretting this line. thanks to any of you javascript wizards that may have a clue. Similar TutorialsHi, i wanted to know whats wrong with this coding as its making the browser crash, firefox 5 $(document).ready(function() { /* open rel=external in new window */ $('a[rel=external]').attr('target', '_blank'); /*Scrolling background clouds */ var offset = 600; var offseta = 1450; function scrollbackground() { // decrease the offset by 1, or if its less than 1 increase it by // the background height minus 1 offset = offset + 1; offseta = offseta + 1; // apply the background position if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) { $('#cloud2').css("background-position", offseta + "px top"); } else { $('#cloud').css("background-position", offset + "px top"); $('#cloud2').css("background-position", offseta + "px top"); } // call self to continue animation setTimeout(function() { scrollbackground(); }, 100 ); } // Start the animation scrollbackground(); }); //end I came across your forums here and it looked like a great place to get some help, and help is exactly what I need! I have been struggling with this javascript that changes an image and its corresponding useMap. For reference: - All images are the same size and located in the same directory, except the main map image - All images are preloaded (I did this just in case it was an image problem) - The page works fine in Firefox, and fine in IE until it crashes - http://www.forthecode.com/imagemap/untitled.htm The Problem: - When clicking on a state in the main image, the state image appears, if you then click on the "return to the overview" it returns to the overview image then promptly crashes IE within 1-2 seconds. - This even happens in a completely blank page (no other content) Exceptions: - Clicking on the state Mississippi does not cause this problem (you can go back and forth with Mississippi without problem) - Tennessee, Ohio, Arkansas, Illonois crash as soon as their state map comes up! The Javascript function itself: Code: <script language="Javascript"> function changemap(vari){ var vari; var stoptime; if(vari=="regionview"){ document.regionmap.src = "/images/branchmap2.jpg"; stoptime = setTimeout( function changemap1(){ document.regionmap.useMap="#Map"; clearTimeout(stoptime);} , 300); } else{ document.regionmap.src = "/images/states/" + vari + ".jpg"; stoptime = setTimeout( function changemap2(){ document.regionmap.useMap="#"+vari; clearTimeout(stoptime);} , 300); } } </script> The image tag and image maps: Code: <img src="images/branchmap2.jpg" name="regionmap" usemap="#Map" border="0"> <map name="Map"> <area shape="rect" coords="144,14,189,91" href="#" onClick="javascript: changemap('indiana');" alt="Indiana" title="Indiana"> <area shape="poly" coords="139,91,137,104,132,108,132,115,128,118,160,110,167,109,189,91" href="#" onClick="javascript: changemap('indiana');" alt="Indiana" title="Indiana"> <area shape="poly" coords="230,138,123,139,121,131,127,122,140,117,153,115,170,107,191,90,194,85,202,87,213,90,221,91,225,90,232,92,232,100,238,107,242,114,245,119" href="#" onClick="javascript: changemap('kentucky');" alt="Kentucky" title="Kentucky"> <area shape="poly" coords="153,177,143,244,144,280,127,287,115,286,113,272,83,271,78,264,86,249,93,239,89,228,88,212,90,202,97,192,105,178" href="#" onMouseUp="javascript: changemap('mississippi');" alt="Mississippi" title="Mississippi"> <area shape="poly" coords="87,226,17,227,16,212,7,212,3,128,108,130,107,142,113,142,120,128,121,131,121,141" href="#" onClick="javascript: changemap('arkansas');" alt="Arkansas" title="Arkansas"> <area shape="poly" coords="246,118,255,98,272,87,284,64,283,11,265,17,258,25,241,31,217,18,187,18,190,81,218,90,224,87,232,92,235,100" href="#" onClick="javascript: changemap('ohio');" alt="Ohio" title="Ohio"> <area shape="poly" coords="124,116,128,121,120,128,111,140,109,129,23,127,21,70,15,60,2,33,74,33,79,39,78,51,95,76,103,77,100,87,101,95,108,103,113,111,114,118" href="#" onClick="javascript: changemap('missouri');" alt="Missouri" title="Missouri"> <area shape="poly" coords="129,117,131,109,136,104,138,91,144,80,142,19,137,4,99,3,102,14,94,22,87,22,90,34,81,45,78,50,94,75,105,77,103,88,104,97,112,107,116,114" href="#" onClick="javascript: changemap('illonois');" alt="Illonois" title="Illonois"> <area shape="poly" coords="204,177,109,176,123,139,249,139" href="#" onMouseUp="javascript: changemap('tennessee');" alt="Tennessee" title="Tennessee"> </map> <map name="arkansas"> <area shape="rect" coords="240,135,284,163" href="/branches/westmemphis.php" alt="West Memphis" title="West Memphis"> <area shape="circle" coords="209,143,7" href="/branches/westmemphis.php" alt="West Memphis" title="West Memphis"> <area shape="rect" coords="130,275,283,290" href="#" onClick="javascript: changemap('regionview');" alt="Overview" title="Overview"> </map> <map name="mississippi"> <area shape="rect" coords="20,177,64,191" href="/branches/jackson.php" alt="Jackson" title="Jackson"> <area shape="circle" coords="103,183,8" href="/branches/jackson.php" alt="Jackson" title="Jackson"> <area shape="rect" coords="217,198,277,214" href="/branches/hattiesburg.php" alt="Hattiesburg" title="Hattiesburg"> <area shape="circle" coords="175,208,7" href="/branches/hattiesburg.php" alt="Hattiesburg" title="Hattiesburg"> <area shape="rect" coords="222,96,279,111" href="/branches/columbus.php" alt="Columbus" title="Columbus"> <area shape="circle" coords="195,106,8" href="/branches/columbus.php" alt="Columbus" title="Columbus"> <area shape="rect" coords="222,71,261,85" href="/branches/tupelo.php" alt="Tupelo" title="Tupelo"> <area shape="circle" coords="174,84,6" href="/branches/tupelo.php" alt="Tupelo" title="Tupelo"> <area shape="rect" coords="130,275,283,290" href="#" onClick="javascript: changemap('regionview');" alt="Overview" title="Overview"> </map> <map name="missouri"> <area shape="rect" coords="195,262,243,275" href="/branches/sikeston.php" alt="Sikeston" title="Sikeston"> <area shape="circle" coords="216,199,7" href="/branches/sikeston.php" alt="Sikeston" title="Sikeston"> <area shape="rect" coords="247,173,280,186" href="/branches/ozora.php" alt="Ozora" title="Ozora"> <area shape="circle" coords="206,182,6" href="/branches/ozora.php" alt="Ozora" title="Ozora"> <area shape="rect" coords="232,158,278,169" href="/branches/sullivan.php" alt="Sullivan" title="Sullivan"> <area shape="circle" coords="194,165,7" href="/branches/sullivan.php" alt="Sullivan" title="Sullivan"> <area shape="rect" coords="228,128,275,142" href="/branches/stlouis.php" alt="St. Louis" title="St. Louis"> <area shape="circle" coords="206,137,8" href="/branches/stlouis.php" alt="St Louis" title="St Louis"> <area shape="rect" coords="198,97,258,112" href="/branches/wentzville.php" alt="Wentzville" title="Wentzville"> <area shape="circle" coords="182,130,6" href="/branches/wentzville.php" alt="Wentzville" title="Wentzville"> <area shape="rect" coords="130,275,283,290" href="#" onClick="javascript: changemap('regionview');" alt="Overview" title="Overview"> </map> <map name="kentucky"> <area shape="rect" coords="24,218,72,231" href="/branches/paducah.php" alt="Paducah" title="Paducah"> <area shape="circle" coords="46,190,6" href="/branches/paducah.php" alt="Paducah" title="Paducah"> <area shape="rect" coords="35,127,95,141" href="/branches/henderson.php" alt="Henderson" title="Henderson"> <area shape="circle" coords="63,174,7" href="/branches/henderson.php" alt="Henderson" title="Henderson"> <area shape="rect" coords="94,218,175,232" href="/branches/bowlinggreen.php" alt="Bowling Green" title="Bowling Green"> <area shape="circle" coords="127,188,6" href="/branches/bowlinggreen.php" alt="Bowling Green" title="Bowling Green"> <area shape="rect" coords="108,75,159,90" href="/branches/louisville.php" alt="Louisville" title="Louisville"> <area shape="circle" coords="144,130,7" href="/branches/louisville.php" alt="Louisville" title="Louisville"> <area shape="rect" coords="179,75,232,89" href="/branches/georgetown.php" alt="Lexington" title="Lexington"> <area shape="circle" coords="193,127,8" href="/branches/georgetown.php" alt="Lexington" title="Lexington"> <area shape="rect" coords="130,275,283,290" href="#" onClick="javascript: changemap('regionview');" alt="Overview" title="Overview"> </map> <map name="indiana"> <area shape="rect" coords="18,199,73,213" href="/branches/vincennes.php" alt="Vincennes" title="Vincennes"> <area shape="circle" coords="110,204,6" href="/branches/vincennes.php" alt="Vincennes" title="Vincennes"> <area shape="rect" coords="210,180,273,193" href="/branches/clarksville.php" alt="Clarksville" title="Clarksville"> <area shape="circle" coords="187,186,6" href="/branches/clarksville.php" alt="Clarksville" title="Clarksville"> <area shape="rect" coords="211,117,276,132" href="/branches/indianapolis.php" alt="Indianapolis" title="Indianapolis"> <area shape="circle" coords="159,124,5" href="/branches/indianapolis.php" alt="Indianapolis" title="Indianapolis"> <area shape="rect" coords="211,101,250,113" href="/branches/muncie.php" alt="Muncie" title="Muncie"> <area shape="circle" coords="178,116,7" href="/branches/muncie.php" alt="Muncie" title="Muncie"> <area shape="rect" coords="212,46,257,60" href="/branches/fremont.php" alt="Fremont" title="Fremont"> <area shape="circle" coords="185,55,7" href="/branches/fremont.php" alt="Fremont" title="Fremont"> <area shape="rect" coords="36,73,92,86" href="/branches/ftwayne.php" alt="Ft. Wayne" title="Ft. Wayne"> <area shape="circle" coords="179,79,5" href="/branches/ftwayne.php" alt="Ft. Wayne" title="Ft. Wayne"> <area shape="rect" coords="36,109,87,121" href="/branches/lafayette.php" alt="Lafayette" title="Lafayette"> <area shape="circle" coords="138,113,6" href="/branches/lafayette.php" alt="Lafayette" title="Lafayette"> <area shape="rect" coords="130,275,283,290" href="#" onClick="javascript: changemap('regionview');" alt="Overview" title="Overview"> </map> <map name="illonois"> <area shape="rect" coords="28,184,89,197" href="/branches/estlouis.php" alt="East St. Louis" title="East St. Louis"> <area shape="circle" coords="126,192,6" href="/branches/estlouis.php" alt="East St. Louis" title="East St. Louis"> <area shape="circle" coords="148,153,5" href="/branches/effingham.php" alt="Effingham" title="Effingham"> <area shape="rect" coords="218,146,273,159" href="/branches/effingham.php" alt="Effingham" title="Effingham"> <area shape="rect" coords="219,120,260,134" href="/branches/urbana.php" alt="Urbana" title="Urbana"> <area shape="circle" coords="164,130,6" href="/branches/urbana.php" alt="Urbana" title="Urbana"> <area shape="rect" coords="130,275,283,290" href="#" onClick="javascript: changemap('regionview');" alt="Overview" title="Overview"> </map> <map name="tennessee"> <area shape="rect" coords="0,199,49,213" href="/branches/memphis.php" alt="Memphis" title="Memphis"> <area shape="circle" coords="25,170,7" href="/branches/memphis.php" alt="Memphis" title="Memphis"> <area shape="rect" coords="41,80,90,94" href="/branches/jacksontn.php" alt="Jackson" title="Jackson"> <area shape="circle" coords="64,149,8" href="/branches/jacksontn.php" alt="Jackson" title="Jackson"> <area shape="rect" coords="130,275,283,290" href="#" onClick="javascript: changemap('regionview');" alt="Overview" title="Overview"> </map> <map name="ohio"> <area shape="rect" coords="49,221,105,237" href="/branches/cincinatti.php" alt="Cincinatti" title="Cincinatti"> <area shape="circle" coords="74,162,7" href="/branches/cincinatti.php" alt="Cincinatti" title="Cincinatti"> <area shape="rect" coords="6,138,46,151" href="/branches/dayton.php" alt="Dayton" title="Dayton"> <area shape="circle" coords="91,146,6" href="/branches/dayton.php" alt="Dayton" title="Dayton"> <area shape="rect" coords="130,275,283,290" href="#" onClick="javascript: changemap('regionview');" alt="Overview" title="Overview"> </map> This is exactly how it is in my html files. I really appreciate any input, suggestions or comments you can give me. Thanks in advance! Hi, here's the code Code: <div class="artworkdelete"> <a href="javascript:void(0);" id="del_<?=$artworkDetails['artwork_id'] ?>_<?=$temp_cat_id; ?>" onclick="deleteThisArtWork(this.id)">Delete</a> </div> that's actually a "Delete" link , when I click it, there's a some sort of loading animation like stuff , similar to the thing that appears when one clicks the edit button of a thread here in this forum..then and it deletes the data and doesn't need to refresh the page, i guess it is ajax.....it's not my code.. now I was asked to alter it and use a pop up box to ask the clicker "Yes" or "No" before deleting the data , what or how to change that code snippet i pasted above ? Hello, I have something like this: Code: function asd() { var timeout = setInterval('alert(\'asd\')', 3000); } function asd2() { // with this function I want to remove the interval of 3 seconds for variable timeout. } I have variable timeout and with the second function asd2() I want to remove this variable. Delete this post. Thank you
I am trying to delete or hide better to say advertisment on Forumotion forum. http://testforum-lolz.serbianforum.info/ When you use firebug to inspect you can find this: Code: html body .w74704f, html body .w74704f iframe, html body iframe[name="google_ads_frame"], html body .w74704f iframe[name="google_ads_frame"], html body #wrap #page-body div.w74704f, html body #page-body .w74704f { bottom: inherit !important; display: block !important; float: none !important; left: inherit !important; margin: 0 auto !important; opacity: 1 !important; padding: inherit !important; position: inherit !important; right: inherit !important; text-align: center !important; top: inherit !important; visibility: visible !important; z-index: 9999 !important; } html body .w74704f, html body .w74704f iframe[name="google_ads_frame"] { height: 90px !important; min-height: 90px !important; width: 728px !important; } html body .w74704f iframe { border: 0 none !important; } html body iframe[name="google_ads_frame"] { height: inherit !important; min-height: inherit !important; width: 100% !important; } When i type display:none; in every single code so I can hide it it doesent work. I dont know can there be any javascript for it. Maybe this can help: Hi all! I created a form where users are allowed to delete a specific row of data by clicking the "cancel" button from the drop down menu. However, I have a problem deleting my data using the javascript. Apparently, I only able to delete the first row of the data but not for the rest! The following is the code i have: PHP Code: <html> <body style="background-color:#E0FFFF;"> <script language="javascript" > <!-- hide function submitRequest(val) { document.forms[0].submit(); } // end hide --> </script> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_course", $con); $result = mysql_query("SELECT * FROM Courses ORDER BY Year, Sem, CourseCode"); $result1 = mysql_query("SELECT * FROM Courses ORDER BY Year, Sem, CourseCode"); echo "<table border='1' cellpadding='2' cellspacing='0'> <tr> <th>CourseCode</th> <th>CourseName</th> <th>Year</th> <th>Sem</th> <th>Grade</th> <th>Option</th> </tr>"; ?> <?php while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['CourseCode'] . "</td>"; echo "<td>" . $row['CourseName'] . "</td>"; echo "<td>" . $row['Year'] . "</td>"; echo "<td>" . $row['Sem'] . "</td>"; echo "<td>" . $row['Grade'] . "</td>"; echo "<td>"; ?> <?php ?> <form name="form1" action="submitDelete.php" method="post"> <select name="cancel" onchange="submitRequest(this.value);"> <option value=> </option> <option value="<?php echo $row['CourseName'];?>">Cancel</option> </select> </form> <?php echo "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> <br/> <br/> </body> </html> Thanks in advance! IS THIS THE CORRECT CODE ??????????? <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="test_mysql"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> This function is part of a page that will delete a product that a customer has selected. The question I have is what is the line line that actually removes the item from the list of products chosen? From my understanding, in order to establish an array, new array = elements[i] has to be added but Im thinking that elements[i] is the array that holds the product. Does the "0" in this line actually delete the item? document.template.elements[i].value = 0 ; Code: function del_item(X,msg) { // var msg = "Are you sure you want to delete this line item?" resp = confirm("Are you sure you want to " + msg + "?") ; if (resp) { var len = document.template.elements.length //loop to put into arrays for (var i = 0; i < len; i++) { var lname = document.template.elements[i].name ; if(lname == X) { document.template.elements[i].value = 0 ; process_order(0) ; document.template.loginpath.value = "CO" ; document.template.submit() ; } } } else { return ; } } I have been searching the internet for thhe past hour trying to find this and searched this forum, I am trying to Delete my cookie with a button. On my websitr I have a cookie to remember the name of the user, I want them to be able to change their name with a button. so delete cookie. How can this be done? The cookie names its seld "UserName" if this helps. hi I do not know why the cookies can't be deleted Code: function deleteCookies() { var splitC=document.cookie.split(";"); var i; for(i=0;i<splitC.length;i++) { var getName=splitC[i].split("="); var cookieDelete = getName[0].replace(/^\s+|\s+$/g, ''); document.cookie=cookieDelete+"=0;expires=Thu, 01-Jan-70 00:00:01 GMT"; } } Hi I really really really need your help since I have no idea about this. How can I insert the Javascript Confirmation Alert into the del.php file? I have this del.php file PHP Code: <?php require ("include/config.php"); $id=$_REQUEST['id']; $strSQL = "DELETE FROM change WHERE id = '".$id."' "; $objQuery = odbc_exec($conn,$strSQL); if($objQuery) { echo "<script language='Javascript'>alert('Deleted.'); window.location=\""."index.php?action=syif\"</script>"; } else { echo "Error Delete [".$strSQL."]"; } odbc_close($conn); ?> This is the confirmation javascript Code: <html> <head> <script type="text/javascript"> function show_confirm() { var r=confirm("Delete?"); if (r==true) { alert("Deleted!"); } else { alert("Cancelled!"); } } </script> </head> <body> <input type="button" onclick="show_confirm()" value="Show confirm box" /> </body> </html> I found a very intressting JS function at this webpage: http://www.dynamicdrive.com/dynamici...edcollapse.htm I wonder if someone knows wihich part from the JS-file i should change/delete so i only get the fade at exempel 1 and not the slide/rolling effect. I only want the fade. The JS is: Code: //** Animated Collapsible DIV v2.0- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com. //** May 24th, 08'- Script rewritten and updated to 2.0. //** June 4th, 08'- Version 2.01: Bug fix to work with jquery 1.2.6 (which changed the way attr() behaves). //** March 5th, 09'- Version 2.2, which adds the following: //1) ontoggle($, divobj, state) event that fires each time a DIV is expanded/collapsed, including when the page 1st loads //2) Ability to expand a DIV via a URL parameter string, ie: index.htm?expanddiv=jason or index.htm?expanddiv=jason,kelly //** March 9th, 09'- Version 2.2.1: Optimized ontoggle event handler slightly. //** July 3rd, 09'- Version 2.4, which adds the following: //1) You can now insert rel="expand[divid] | collapse[divid] | toggle[divid]" inside arbitrary links to act as DIV togglers //2) For image toggler links, you can insert the attributes "data-openimage" and "data-closedimage" to update its image based on the DIV state var animatedcollapse={ divholders: {}, //structu {div.id, div.attrs, div.$divref, div.$togglerimage} divgroups: {}, //structu {groupname.count, groupname.lastactivedivid} lastactiveingroup: {}, //structu {lastactivediv.id} preloadimages: [], show:function(divids){ //public method if (typeof divids=="object"){ for (var i=0; i<divids.length; i++) this.showhide(divids[i], "show") } else this.showhide(divids, "show") }, hide:function(divids){ //public method if (typeof divids=="object"){ for (var i=0; i<divids.length; i++) this.showhide(divids[i], "hide") } else this.showhide(divids, "hide") }, toggle:function(divid){ //public method if (typeof divid=="object") divid=divid[0] this.showhide(divid, "toggle") }, addDiv:function(divid, attrstring){ //public function this.divholders[divid]=({id: divid, $divref: null, attrs: attrstring}) this.divholders[divid].getAttr=function(name){ //assign getAttr() function to each divholder object var attr=new RegExp(name+"=([^,]+)", "i") //get name/value config pair (ie: width=400px,) return (attr.test(this.attrs) && parseInt(RegExp.$1)!=0)? RegExp.$1 : null //return value portion (string), or 0 (false) if none found } this.currentid=divid //keep track of current div object being manipulated (in the event of chaining) return this }, showhide:function(divid, action){ var $divref=this.divholders[divid].$divref //reference collapsible DIV if (this.divholders[divid] && $divref.length==1){ //if DIV exists var targetgroup=this.divgroups[$divref.attr('groupname')] //find out which group DIV belongs to (if any) if ($divref.attr('groupname') && targetgroup.count>1 && (action=="show" || action=="toggle" && $divref.css('display')=='none')){ //If current DIV belongs to a group if (targetgroup.lastactivedivid && targetgroup.lastactivedivid!=divid) //if last active DIV is set this.slideengine(targetgroup.lastactivedivid, 'hide') //hide last active DIV within group first this.slideengine(divid, 'show') targetgroup.lastactivedivid=divid //remember last active DIV } else{ this.slideengine(divid, action) } } }, slideengine:function(divid, action){ var $divref=this.divholders[divid].$divref var $togglerimage=this.divholders[divid].$togglerimage if (this.divholders[divid] && $divref.length==1){ //if this DIV exists var animateSetting={height: action} if ($divref.attr('fade')) animateSetting.opacity=action $divref.animate(animateSetting, $divref.attr('speed')? parseInt($divref.attr('speed')) : 500, function(){ if ($togglerimage){ $togglerimage.attr('src', ($divref.css('display')=="none")? $togglerimage.data('srcs').closed : $togglerimage.data('srcs').open) } if (animatedcollapse.ontoggle){ try{ animatedcollapse.ontoggle(jQuery, $divref.get(0), $divref.css('display')) } catch(e){ alert("An error exists inside your \"ontoggle\" function:\n\n"+e+"\n\nAborting execution of function.") } } }) return false } }, generatemap:function(){ var map={} for (var i=0; i<arguments.length; i++){ if (arguments[i][1]!=null){ //do not generate name/value pair if value is null map[arguments[i][0]]=arguments[i][1] } } return map }, init:function(){ var ac=this jQuery(document).ready(function($){ animatedcollapse.ontoggle=animatedcollapse.ontoggle || null var urlparamopenids=animatedcollapse.urlparamselect() //Get div ids that should be expanded based on the url (['div1','div2',etc]) var persistopenids=ac.getCookie('acopendivids') //Get list of div ids that should be expanded due to persistence ('div1,div2,etc') var groupswithpersist=ac.getCookie('acgroupswithpersist') //Get list of group names that have 1 or more divs with "persist" attribute defined if (persistopenids!=null) //if cookie isn't null (is null if first time page loads, and cookie hasnt been set yet) persistopenids=(persistopenids=='nada')? [] : persistopenids.split(',') //if no divs are persisted, set to empty array, else, array of div ids groupswithpersist=(groupswithpersist==null || groupswithpersist=='nada')? [] : groupswithpersist.split(',') //Get list of groups with divs that are persisted jQuery.each(ac.divholders, function(){ //loop through each collapsible DIV object this.$divref=$('#'+this.id) if ((this.getAttr('persist') || jQuery.inArray(this.getAttr('group'), groupswithpersist)!=-1) && persistopenids!=null){ //if this div carries a user "persist" setting, or belong to a group with at least one div that does var cssdisplay=(jQuery.inArray(this.id, persistopenids)!=-1)? 'block' : 'none' } else{ var cssdisplay=this.getAttr('hide')? 'none' : null } if (urlparamopenids[0]=="all" || jQuery.inArray(this.id, urlparamopenids)!=-1){ //if url parameter string contains the single array element "all", or this div's ID cssdisplay='block' //set div to "block", overriding any other setting } else if (urlparamopenids[0]=="none"){ cssdisplay='none' //set div to "none", overriding any other setting } this.$divref.css(ac.generatemap(['height', this.getAttr('height')], ['display', cssdisplay])) this.$divref.attr(ac.generatemap(['groupname', this.getAttr('group')], ['fade', this.getAttr('fade')], ['speed', this.getAttr('speed')])) if (this.getAttr('group')){ //if this DIV has the "group" attr defined var targetgroup=ac.divgroups[this.getAttr('group')] || (ac.divgroups[this.getAttr('group')]={}) //Get settings for this group, or if it no settings exist yet, create blank object to store them in targetgroup.count=(targetgroup.count||0)+1 //count # of DIVs within this group if (jQuery.inArray(this.id, urlparamopenids)!=-1){ //if url parameter string contains this div's ID targetgroup.lastactivedivid=this.id //remember this DIV as the last "active" DIV (this DIV will be expanded). Overrides other settings targetgroup.overridepersist=1 //Indicate to override persisted div that would have been expanded } if (!targetgroup.lastactivedivid && this.$divref.css('display')!='none' || cssdisplay=="block" && typeof targetgroup.overridepersist=="undefined") //if this DIV was open by default or should be open due to persistence targetgroup.lastactivedivid=this.id //remember this DIV as the last "active" DIV (this DIV will be expanded) this.$divref.css({display:'none'}) //hide any DIV that's part of said group for now } }) //end divholders.each jQuery.each(ac.divgroups, function(){ //loop through each group if (this.lastactivedivid && urlparamopenids[0]!="none") //show last "active" DIV within each group (one that should be expanded), unless url param="none" ac.divholders[this.lastactivedivid].$divref.show() }) if (animatedcollapse.ontoggle){ jQuery.each(ac.divholders, function(){ //loop through each collapsible DIV object and fire ontoggle event animatedcollapse.ontoggle(jQuery, this.$divref.get(0), this.$divref.css('display')) }) } //Parse page for links containing rel attribute var $allcontrols=$('a[rel]').filter('[rel^="collapse["], [rel^="expand["], [rel^="toggle["]') //get all elements on page with rel="collapse[]", "expand[]" and "toggle[]" $allcontrols.each(function(){ //loop though each control link this._divids=this.getAttribute('rel').replace(/(^\w+)|(\s+)/g, "").replace(/[\[\]']/g, "") //cache value 'div1,div2,etc' within identifier[div1,div2,etc] if (this.getElementsByTagName('img').length==1 && ac.divholders[this._divids]){ //if control is an image link that toggles a single DIV (must be one to one to update status image) animatedcollapse.preloadimage(this.getAttribute('data-openimage'), this.getAttribute('data-closedimage')) //preload control images (if defined) $togglerimage=$(this).find('img').eq(0).data('srcs', {open:this.getAttribute('data-openimage'), closed:this.getAttribute('data-closedimage')}) //remember open and closed images' paths ac.divholders[this._divids].$togglerimage=$(this).find('img').eq(0) //save reference to toggler image (to be updated inside slideengine() ac.divholders[this._divids].$togglerimage.attr('src', (ac.divholders[this._divids].$divref.css('display')=="none")? $togglerimage.data('srcs').closed : $togglerimage.data('srcs').open) } $(this).click(function(){ //assign click behavior to each control link var relattr=this.getAttribute('rel') var divids=(this._divids=="")? [] : this._divids.split(',') //convert 'div1,div2,etc' to array if (divids.length>0){ animatedcollapse[/expand/i.test(relattr)? 'show' : /collapse/i.test(relattr)? 'hide' : 'toggle'](divids) //call corresponding public function return false } }) //end control.click })// end control.each $(window).bind('unload', function(){ ac.uninit() }) }) //end doc.ready() }, uninit:function(){ var opendivids='', groupswithpersist='' jQuery.each(this.divholders, function(){ if (this.$divref.css('display')!='none'){ opendivids+=this.id+',' //store ids of DIVs that are expanded when page unloads: 'div1,div2,etc' } if (this.getAttr('group') && this.getAttr('persist')) groupswithpersist+=this.getAttr('group')+',' //store groups with which at least one DIV has persistance enabled: 'group1,group2,etc' }) opendivids=(opendivids=='')? 'nada' : opendivids.replace(/,$/, '') groupswithpersist=(groupswithpersist=='')? 'nada' : groupswithpersist.replace(/,$/, '') this.setCookie('acopendivids', opendivids) this.setCookie('acgroupswithpersist', groupswithpersist) }, getCookie:function(Name){ var re=new RegExp(Name+"=[^;]*", "i"); //construct RE to search for target name/value pair if (document.cookie.match(re)) //if cookie found return document.cookie.match(re)[0].split("=")[1] //return its value return null }, setCookie:function(name, value, days){ if (typeof days!="undefined"){ //if set persistent cookie var expireDate = new Date() expireDate.setDate(expireDate.getDate()+days) document.cookie = name+"="+value+"; path=/; expires="+expireDate.toGMTString() } else //else if this is a session only cookie document.cookie = name+"="+value+"; path=/" }, urlparamselect:function(){ window.location.search.match(/expanddiv=([\w\-_,]+)/i) //search for expanddiv=divid or divid1,divid2,etc return (RegExp.$1!="")? RegExp.$1.split(",") : [] }, preloadimage:function(){ var preloadimages=this.preloadimages for (var i=0; i<arguments.length; i++){ if (arguments[i] && arguments[i].length>0){ preloadimages[preloadimages.length]=new Image() preloadimages[preloadimages.length-1].src=arguments[i] } } } } Greetings: On the click of a button, how would I delete a certain record in a database table, w/o refreshing the page? I am new to JS and don't even know where to start. Thanks in advance. Hi I am working on a .net basket where I save the info for the products in the basket etc in a cookie. Now I have an html button on the basket page where I want to be able to delete the product (Cookie). I am using Code: <script type="text/javascript"> function delete_cookie ( cookie_name ) { expires = Now(); document.cookie = cookie_Name+"= ;expires="+expires.toGMTString(); } </script>But I get an error that says the cookie is not delcared? But it does exist because I retrive the name of the cookie when looping through the cookie list. What am I doing wrong here? i hava e java script fr confrmation of record deletion on server side in asp.net function deleteCheck() { if (document.getElementById('H_ctrl').value!="") { alert(document.getElementById('H_ctrl').value) var delconfirm = confirm('Are you sure ? You want to delete ' + document.getElementById('H_ctrl').value +' Details ?') if (delconfirm==true) { var delconfirmAgain = confirm('The Record ' + document.getElementById('H_ctrl').value +' will be deleted permanently. Are you sure? ') if(delconfirmAgain==true) { return true } else { return false } } else { return false } } } BTNDELETE.Attributes("onclick") = "javascript:return deleteCheck();" in the button event i have a query for redord deletion i need to delete the records if u use the return keyword the record doesnot get deleted but if i remove the return keyowrd the record gets deleted even if CANCEL is clicked Hello, I have a script that lets you add tasks to a task list and then you can click a button to sort them, but I cannot get the "Delete Selected Task" and "Delete All Tasks" buttons to work correctly. I will be eternally indebted to whoever can help me fix these two buttons. The code I am working on is posted below. Thank you for your time. [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>To Do List</title> <script type="text/javascript"> /* <![CDATA[ */ function addTask() { if (document.forms[0].newtask.value == "") window.alert("You must enter a value in the New Task field."); else { if (document.forms[0].tasks.options.value == "tasks") document.forms[0].tasks.options[0] = null; var newTask = new Option(); newTask.value = document.forms[0].newtask.value; newTask.text = document.forms[0].newtask.value; var numTasks = document.forms[0].tasks.options.length; document.forms[0].tasks.options[numTasks] = newTask; document.forms[0].newtask.value = ""; } } function deleteTask() { var selectedTask = 0; var taskSelected = false; while (selectedTask < document.forms[0].tasks.length) { if (document.forms[0].tasks.options[selectedTask].selected == true) { taskSelected = true; break; } ++selectedTask; } if (taskSelected == true) document.forms[0].tasks.options[selectedTasks] = null; else window.alert("You must select a task in the list."); } function ascendingSort() { var newTasks = new Array(); for (var i =0; i < document.forms[0].tasks.length; ++i) { newTasks[i] = document.forms[0].tasks.options[i].value; } newTasks.sort(); for (var j =0; j < document.forms[0].tasks.length; ++j) { document.forms[0].tasks.options[j].value = newTasks[j]; document.forms[0].tasks.options[j].text = newTasks[j]; } } /* ]]> */ </script> </head> <body> <h1>To Do List</h1> <form action=""> <p>New Task <input type="text" size="68" name="newtask" /></p> <p><input type="button" value="Add Task" onclick="addTask()" style="width: 150px" /> <input type="button" value="Delete Selected Task" onclick="deleteTask()" style="width: 150px" /> <input type="button" value="Delete All Tasks" onclick="document.forms[0].task.options.length = 0;" style="width: 150px" /><br /> <input type="button" value="Ascending Sort" onclick="ascendingSort()" style="width: 150px" /> </p> <p><select name="tasks" size="10" style="width: 500px"> <option value="tasks">Tasks</option></select></p> </form> </body> </html> [CODE] I have a HTML table with 800 rows. How can I delete rows that has no Activity & no $ in JavaScript(Orange Colored Rows)? Please note I can have 1 or more than 1 assessments with 1 or more than 1 activity. Sample data. Name Address Assessment Activity $ Bela Toronto First Assesment Activity 1 10 Asif Toronto First Assesment Asif Toronto First Assesment Activity 1 10 Asif Toronto First Assesment Activity 2 10 Asif Toronto First Assesment Activity 3 20 Asif Toronto First Assesment Activity 4 30 Asif Toronto Second Assesment Asif Toronto Second Assesment Activity 1 10 Asif Toronto Second Assesment Activity 2 10 Asif Toronto Second Assesment Activity 3 10 Akhtar Toronto First Assesment Akhtar Toronto First Assesment Activity 1 20 Akhtar Toronto First Assesment Activity 2 30 Akhtar Toronto First Assesment Activity 3 10 Akhtar Toronto First Assesment Activity 4 10 Akhtar Toronto First Assesment Activity 5 10 I have a table that has a series of dropdowns. Each dropdown is build with JavaScript based on the values of the prior dropdowns. The data for each of these dropdowns comes from a series of XML files which are loaded into a series of arrays on loading. This is all working. What I need (but can't figure out) is how to dynamically build a sub-table within a specific cell of the parent table based on the values of the prior dropdowns and if the prior dropdowns are changed, how do delete (not just hide) the dynamic table and rebuild it based on the values of the new dropdowns. Code: this.delete = function(obj) { .. Is that it ? I can't have delete ? Or can this be written in some other way, including delete ? |