Jump to content
php.lv forumi

input button


sidrs

Recommended Posts

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 by rATRIJS
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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 by Maris-S
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...