sidrs Posted February 14, 2011 Report Share Posted February 14, 2011 man vajag panākt lai input pogai būtu laika ierobežojums 5 sec. varbūt kādam ir kāds links ar tutoriāli par šādu lietu? nospied un poga paliek uz 5 sec disablēta un pēc 5 sec tik var nospiest atkal Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted February 14, 2011 Report Share Posted February 14, 2011 (edited) jQuery('input#button').click(function() { var button = jQuery(this); button.attr('disabled', true); setTimeout(function() { button.attr('disabled', false); }, 5000); return true; }); Tas ir izmantojot jQuery. Protams, to var izdariit arii bez taa... Edited February 14, 2011 by rATRIJS Quote Link to comment Share on other sites More sharing options...
sidrs Posted February 14, 2011 Author Report Share Posted February 14, 2011 man jquery biki vel patumša bilde. izradijas ka man ta ir type=submit . un ja ir blakus vairakas tadas un vajag disablēt vienu, tad japiešuj vel id klāt? un kas pogā jāraksta lai funkcija izpildītos? Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted February 14, 2011 Report Share Posted February 14, 2011 Jup - ja gribi lai tas attiecas tikai uz vienu bildi tad pieliec kaadu ID. Ja tev ir poga: <input type="submit" id="mana-poga" /> Tad ar jQuery tu vinju dabuutu shaadi: jQuery('#mana-poga') Pogai vairaak neko klaat nevajag. Tik iekljauj jQuery biblioteeku un to koda gabalu. Quote Link to comment Share on other sites More sharing options...
sidrs Posted February 14, 2011 Author Report Share Posted February 14, 2011 saliku šādi, nestrādā, kur varetu but kluda <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>test</title> <script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"> </script> <script type="text/javascript"> jQuery('input#fight').click(function() { var button = jQuery(this); button.attr('disabled', true); setTimeout(function() { button.attr('disabled', false); }, 5000); return true; }); </script> </head> <body> <input id="fight" type="submit" value="poga"/> </body> </html> Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted February 14, 2011 Report Share Posted February 14, 2011 To manu koda gabalu var izsaukt tikai tad, kad DOM ir gatavs. Vai nu iekljauj vinju pirms aizveroshaa body taga vai pievieno eventu kad DOM ir gatavs. Tas izskatiitos shaadi: jQuery(function() { /* Te iet mans koda gabals ko iedevu */ }); btw jaunaakaa jQuery versija ir 1.5.* Quote Link to comment Share on other sites More sharing options...
sidrs Posted February 14, 2011 Author Report Share Posted February 14, 2011 jup, tagad aizgāja tik sākās nākamais :D pēc lapas pārlādes, tas ir posta izpildes, disabls nometas nost :) Quote Link to comment Share on other sites More sharing options...
Maris-S Posted February 14, 2011 Report Share Posted February 14, 2011 (edited) Es gan taisītu šādas liets bez jquery, protams ja tā nav vienīgā lieta kur izmanto jquery, tad tomēr var arī viņu izmantot. <form name="form_name" action="" method="post"> <div> <input type="submit" name="button_name" value="Nosūtīt" onclick="javascript: this.disabled = true; setTimeout(function() { document.form_name.button_name.disabled = false; }, 5000); return false;"> </div> </form> Return false šoreiz uzliku, lai nenotiek submits, bet cik skatos Tev to lietu jātaisa izmantojot visu submitu. Tātad doma sekojoša, ja tika submitoti dati, tad uzreiz noklusēti liec pogai disabled un timeouta funkciju, kas ieslēgs atkal viņu. Pirmo reizi kad atver lapu (netika veikts submits), atstāj pogu vienkārši enabled. Edited February 14, 2011 by Maris-S Quote Link to comment Share on other sites More sharing options...
sidrs Posted February 14, 2011 Author Report Share Posted February 14, 2011 a ja uz pogas izpildas jau viens onclick vinjam divus var apvienot lai abi izpildas? Quote Link to comment Share on other sites More sharing options...
Maris-S Posted February 16, 2011 Report Share Posted February 16, 2011 Sataisi atsevišķu funkciju, kura izpildīs šīs divas darbības un tad uz onclick izsauc sataisīto funkciju. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.