form submit - Javascript Disabling and Timing -


i need update application when user clicks on button, etc of input fields become disabled. here have far javascript. following works , everything, no worries there.

function disableallinputs() {     var inputs = getallinputs();     (i = 0; < inputs.length; i++) {         inputs[i].disabled = true;     } }   function enableallinputs() {     var inputs = getallinputs();     (i = 0; < inputs.length; i++) {         inputs[i].disabled = false;     } }  function getallinputs() {     var inputs = document.getelementsbytagname('input');     var selects = document.getelementsbytagname('select');      var allinputs = new array();      var counter = 0;     (i = 0; < inputs.length ; i++) {         allinputs[counter] = inputs[i];         counter++;     }     (i = 0; < selects.length; i++) {         allinputs[counter] = selects[i];         counter++;     }      return allinputs; } 

now, in html have this:

<form name="myform" method="post" action="myaction.do" onsubmit="onsubmit();">     //form code     <input type="submit" value="save" name="submit" onclick="onsaveclick()" > </form> 

everything appears work fine. however, need make testable. i'd put in delay freezes , tester can make sure disabled, etc. pausing should temporary , removable without possible side effects (i.e. nice call pause() function , delete call).

here issues:

1 - if call disableallinputs method in onsaveclick method, form not submit (i assume because button disabled).

2 - if call disableallinputs method in onsubmit method, pausing not appear work.

can think of way seamlessly pause form submission after buttons disabled? aware of settimeout, etc. can't find appropriate call location, etc use. nothing seems pause form , submit form.

also, i'd have js in separate .js file, nice if include file , add disableallinputs method appropriate (that is, i'd avoid doing timeout on onsubmit method, etc).

well, can insert pause using various methods, of methods cause entire page become unresponsive during pause. simplest example of alert box. (you use sjax - synchronous ajax.)

you stop code triggering fatal error, such calling function doesn't exist. stopjavascript(); wouldn't allow code continue anymore.

the other option split function 2 functions , use settimeout delay calling of second function after first. however, harder implement , harder remove.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -