Afisare Loading apoi Redirect dupa apasare Submit

Discutii si intrebari legate de scripturi si functii JavaScript, jQuery si Ajax, cod JavaScript in general.
Bizzar
Mesaje:49

Afisare Loading apoi Redirect dupa apasare Submit

Buna ziua MarPlo!

As vrea un script de tip JS care sa functioneze cam asa: eu stau pe pagina de logare "numesite/login" si as vrea ca cand sa dau click pe butonul "Conectare" sa imi arate un script cu loading, scriptul fiind urmatorul:

Cod: Selectaţi tot

<br>
 <script type="text/JavaScript">
  <!--
    setTimeout("location.href = '/forum';",1900);
  -->
</script>
    <center><strong><font color="white" face="Arial">Bine ati venit pe forumul eXploreCS</font></strong></center><br/>

    <p style="text-align: center;"><a href="http://www.zmexplorecs.forumer.ro"><img alt="" src="http://i49.servimg.com/u/f49/16/79/83/21/login10.gif" width="400" height="52"></a></p><p style="text-align: center;"><br></p><p style="text-align: center;"><br></p>
</p><div style="text-align: right;"><br/>
 <center><a href="http://www.forumgratuit.ro" target="_blank">ForumGratuit</a></center>
<style type="text/css">
    body {
    margin: 0px;
    background: url('http://hitskin.com/themes/14/98/58/i_background.png');
    }
Codul preluat la logare este:

Cod: Selectaţi tot

<form action="/login" method="post" name="form_login"><table align="center" border="0" cellpadding="0" cellspacing="2" width="100%"><tbody><tr><td class="nav"><a class="nav" href="/forum">eXploreCS</a></td></tr></tbody></table><table class="forumline" align="center" border="0" cellpadding="4" cellspacing="0" width="100%"><tbody><tr><th colspan="3" class="thHead" height="25" nowrap="nowrap">Va rugam introduceti un nume de utilizator si o parola pentru a va conecta.</th></tr><tr><td class="row1" align="center" width="100%"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="row1 align_gauche"><table border="0" cellpadding="0" cellspacing="1" width="100%"><tbody><tr><td colspan="2" align="center">&nbsp;</td></tr><tr><td class="align_droite" width="50%"><span class="gen">Utilizator:</span></td><td width="50%"><input name="username" value="" size="25" maxlength="40" type="text"></td></tr><tr><td class="align_droite"><span class="gen">Parola:</span></td><td><input name="password" size="25" maxlength="32" type="password"></td></tr><tr align="center"><td colspan="2"><span class="gen">Conectare automata: <input name="autologin" checked="checked" type="checkbox"></span></td></tr><tr align="center"><td colspan="2"><input name="redirect" value="" type="hidden"><input name="query" value="" type="hidden"><input class="mainoption" name="login" value="Conectare" type="submit"></td></tr><tr align="center"><td colspan="2"><br><span class="gensmall"><a class="gensmall" href="/register">::&nbsp;Inregistrare</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a class="gensmall" href="/profile?mode=sendpassword">::&nbsp;Mi-am uitat parola</a></span></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></form>
Voi fi foarte recunoscator, numai bine! ;)
P.S. As vrea sa imi dai codul JS, si sa nu fie nimic legat de PHP, stiu ca nu e foarte usor, dar sper ca imi vei da un raspuns pozitiv ;)

MarPlo Mesaje:4343
Salut
Incearca urmatorul cod:

Cod: Selectaţi tot

<div id="ldng"></div>
<script type="text/JavaScript">
<!--
function goToPag() { window.location.href = 'forum/'; }
function ldng() {
  document.getElementById('ldng').innerHTML = '<h2>Loading...</h2>';
  setTimeout("goToPag()", 1900);
  return false;
}
-->
</script>
Iar in tag-ul <form> trebuie adaugat: onsubmit="return ldng();" , sa fie asa:
<form action="/login" method="post" name="form_login" onsubmit="return ldng();">.

Subiecte similare