Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript]Odliczanie + button
dk1342
post
Post #1





Grupa: Zarejestrowani
Postów: 275
Pomógł: 9
Dołączył: 24.07.2008
Skąd: Racibórz

Ostrzeżenie: (10%)
X----


Temat do usunięcia

Ten post edytował dk1342 20.10.2008, 14:26:55
Go to the top of the page
+Quote Post
drPayton
post
Post #2





Grupa: Zarejestrowani
Postów: 890
Pomógł: 65
Dołączył: 13.11.2005
Skąd: Olsztyn

Ostrzeżenie: (0%)
-----


Ale koszmarek...
Nawet testować się nie chce... A może to dlatego, że kodu a tagi nie ubrałeś? (IMG:http://forum.php.pl/style_emoticons/default/rolleyes.gif)

  1. <input type="submit" id="ID_buttonu" value="Submit za 10 sekund..." />
  2.  
  3. <script type="text/javascript">
  4. document.getElementById("ID_buttonu").disabled = true;
  5. var counter = 10;
  6. function countdown(counter) {
  7. counter--;
  8. document.getElementById("ID_buttonu").value = 'Submit za ' + counter + ' sekund';
  9. if(counter == 0) {
  10. document.getElementById("ID_buttonu").disabled = false;
  11. document.getElementById("ID_buttonu").value = 'Submit!';
  12. }
  13. return counter;
  14. }
  15. setInterval('counter = parseInt(counter); if(counter > 0) { counter = countdown(counter); }', 1000);


Ten post edytował drPayton 15.10.2008, 19:46:51
Go to the top of the page
+Quote Post
dk1342
post
Post #3





Grupa: Zarejestrowani
Postów: 275
Pomógł: 9
Dołączył: 24.07.2008
Skąd: Racibórz

Ostrzeżenie: (10%)
X----


dzięki "pomógł" dla ciebie

wsadziłem to w php:

Kod
echo '
<input type="submit" id="1" onclick=\'parent.location.href="<?print(http://www.mojastrona.pl/pliki/test/files/" . $id . ");  ?>\'" value="Proszę czekać 10 sekund" />
<script type=\'text/javascript\'>
document.getElementById(\'1\').disabled = true;
var counter = 10;
function countdown(counter) {
counter--;
document.getElementById(\'1\').value = \'Proszę czekać \' + counter + \' sekund\';
if(counter == 0) {
document.getElementById(\'1\').disabled = false;
document.getElementById(\'1\').value = \'Pobierz Plik\';
}
return counter;
}
setInterval(\'counter = parseInt(counter); if(counter > 0) { counter = countdown(counter); }\', 1000);
</script>
';


i odlicza i gdy się skonczy odliczanie jest button pobierz plik ale gdy na niego naciskam nic się nie dzieje muszą się chyba mieszać "" lub '' ale nie wiem gdzie pomoże ktoś ?

@ juz se poradziłem sam sorry


Ten post edytował dk1342 18.10.2008, 11:39:53
Go to the top of the page
+Quote Post
Dingo
post
Post #4





Grupa: Zarejestrowani
Postów: 26
Pomógł: 0
Dołączył: 27.05.2009

Ostrzeżenie: (0%)
-----


Jak by ktoś przez google tu trafił to poprawne rozwiązanie tego problemu jest takie:
  1. <input type="submit" id="1" onclick="parent.location.href=\'http://google.pl\'" value="Proszę czekać 10 sekund" />
  2. <script type=\'text/javascript\'>
  3. document.getElementById(\'1\').disabled = true;
  4. var counter = 10;
  5. function countdown(counter) {
  6. counter--;
  7. document.getElementById(\'1\').value = \'Proszę czekać \' + counter + \' sekund\';
  8. if(counter == 0) {
  9. document.getElementById(\'1\').disabled = false;
  10. document.getElementById(\'1\').value = \'Pobierz Plik\';
  11. }
  12. return counter;
  13. }
  14. setInterval(\'counter = parseInt(counter); if(counter > 0) { counter = countdown(counter); }\', 1000);
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 14:51