Bad Credit Personal Loans - Find jobs - Wordpress Themes - Air Jordans - Debt Consolidation

PDA

View Full Version : When submit the button goes inactive for 30 seconds


human
Aug 25th 2008, 2:23 am
How to make it ?
I'm making an Ajax chat.There are my scripts:
JS:
function form() {
if(document.getElementById(form).style.display == 'block') {
document.getElementById(form).style.display = 'none';
setInterval("form()",30000);
}
else { document.getElementById(form).style.display = 'block'; }
}
HTML
<div id="form" style="display:block;">
The form
</div>
And the PHP script:
echo "Success...
<script type=\"text/javascript\">
form();
</script>";

xlcho
Aug 27th 2008, 4:14 am
You have an error in your JS. It should be:
function form() {
if(document.getElementById('form').style.display == 'block') {
document.getElementById('form').style.display = 'none';
setInterval("form()",30000);
}
else { document.getElementById('form').style.display = 'block'; }
}
cause you wanna access the element with id 'form'. What you've done is accessing the element with an id equal to the variable form, which may hold something else, or even be empty. Another way to do the same is to keep your code, but put the fallowing line before it:
var form = 'form';
This will work, but it's lame and unnecessary, cause this var will not be used for anything else..

Just use my code and learn when to use ' and when not :)

joebert
Aug 29th 2008, 8:49 pm
Use "setTimeout" instead of "setInterval".

Other than that, I'm not quite sure what you're trying to accomplish just by looking at that code.