Jump to content
alexarpad2003

javascript counter

Recommended Posts

Am codul care imi numeroteaza clickurile :

<script type ="text/javascript">
var x = 0;
function count() {
x += 1;
document.getElementById( "counting" ).value = x;
}
</script>

Am formul de genul :

<form method='post'>
<input name='sub' type='submit' value='schimba'/>
</form>

Cum sa scriu conditia ca doar la a 5-a apasare a butonului sub sa-mi proceseze formul ?

Link to comment
Share on other sites

Cam a?a

<input id="counting" value="0"/>
<script type ="text/javascript">
var x = 0;
function count() {
x += 1;
if (x==5)
return true;
document.getElementById("counting" ).value = x;
return false;
}
</script>

<form method='post'>
<input name='sub' type='submit' value='schimba' onclick="return count()" />
</form>

  • Upvote 1
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.



×
×
  • Create New...