This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
java code which does some querying and if some condition is met I set a flag in a hidden variable.
In the next lines of this function code - I compare/check the hidden variable value and decide if I have to give an
alert message and block form submission or not.
Some of the code is as follows:
In the above lines of code always the if(f.block.value == "Y") is false even though it is supposed to be true.
Am I going wrong somewhere or am I missing something?
BUT if I just add this line alert(f.block.value) before if(f.block.value == "Y") it works correct always.
I thought maybe it is because if(f.block.value == "Y") might have run before document.getElementById('block').value = 'Y' in processRequest()
I tried to put some wait/sleep kind of code between but still the if condition is always false but as I said before if I put the alert, it always works correct.
I know I am going wrong somewhere..
I really appreciate your help.. and for your time
TIP: Why set a hidden field then check it? Why not just use your ajax response to determine if the form submission can go through? In addition, why not just let the server decide, since you've already submitted the form.