Tag: javascript events

Javascript check all and uncheck all for checkbox

<script type=”text/javascript”> function checkAll(formname, checktoggle) { var checkboxes = new Array(); checkboxes = document[formname].getElementsByTagName(‘input’); for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].type === ‘checkbox’) { checkboxes[i].checked = checktoggle; } } } </script> <form name=”myform”> <li> <label class=”cba”> <a href=”javascript:void();” onclick=”javascript:checkAll(‘myform’, true);”>Check All</a> | <a href=”javascript:void();” onclick=”javascript:checkAll(‘myform’, false);”>UnCheck All</a> </label> </li> <li> […]

Form Control Workaround – Chrome Error

I am trying to get around the: An invalid form control with name=’dob_mm’ is not focusable. Error that comes in Chrome. Yes, we have a bunch of fields that are required, and yes, these fields are hidden. The form is broken out into tabs, which only one show at a time. Is there some type […]

Alternate to body onload = (string) for Javascript

I’m (somewhat) new to JavaScript and I’m writing a timing plugin that requires <body onload=”mktClock_standard(); setInterval(‘mktClock_standard()’, 1000 ); mktClock_military(); setInterval(‘mktClock_standard()’, 1000 )”> And I was wondering if there’s a way to do that , but in JavaScript, like using window.onload or something. I tried simply: window.onload = mktClock_standard(); setInterval(‘mktClock_standard()’, 1000 ); mktClock_military(); setInterval(‘mktClock_standard()’, 1000 ) […]

Cookie add on button hit

I have a problem with adding a cookie. Read a couple of answers, but it’s hard to understand if you never worked with them before. What I basically want is to add a cookie if someone click on the specified button. So for example, if person clicked on the “like button”, hidden content will be […]

How to Remove dynamic Parent <tr> via OnClick of child <input>

I’m adding the <tr> via a javascript var: var txtBox = “<tr id=’dynTR’><td><input type=’text’ class=’textBoxes’ /></td><td><input type=’text’ class=’textBoxes’ value=’0′ /></td><td><input type=’button’ value=’-‘ /></td></tr>”; With my function being: function AddTR(table) { $(table).append(txtBox); } My table structure (along with the button for the function) in the HTML being: <table id=”tblTest” class=”testTable”> <thead> <tr> <td>Product</td> <td>Quantity</td> <td>Remove TR</td> […]

Copying data from one text box to another using Java Script

I want to copy data from one text box to another in html automatically ie., as I edit the first text box the second one should reflect the same spontaneously

javascript obtain outer parent id DIV

I have a structure that looks like the one below, I’m trying to get the id foo. It is the only DIV with id if we bubble up from the onclick func(), which means that there wont be other DIVs that contain an id inside foo. However, there can be other tags inside foo that […]

Increase and decrease a variable until a number is reached in javascript

how can I increase and decrease a variable in javascript until 100 and when 100 is reached it should start decreasing. So accuracyBarValue should start in 0, increase to 100, and when 100 is reached it should go to 0, and then repeat procedure. This in intervals of 10. I use this in a very […]

IEs understanding of 'this'

In this code, Firefox sees ‘this’ as the element that was clicked and passes the href attribute through the right way. IE seems to think that ‘this’ as [object window] instead. How would I get this to work the same way in both browsers? Note: jQuery would be lovely, but is not an option for […]

How can I prevent a page unload with jQuery?

In my program, if a user tries to leave a page, he’ll receive a dialog box asking if he is sure he wants to leave. How should I implement the ‘cancel’ option if the user chooses not to leave the page? Source javascript code: $(window).unload(function(){ var c= confirm (“Are you sure?”); if (c){ alert(“Thanks. Good […]