I have a randomiser, and I want to add a counting system that shows how many times a certain result came out. For example: if I enter Hello and Goodbye, it has to count the times Hello came out, same for Goodbye. If possible, users have to select the max. score they want. For example: 3/5, 5/7 etc... Can you also put a reset button in the code to reset the code and the scores? Here's my code for the randomiser:
<script src="http://ift.tt/1oMJErh"></script>
<form>
<hr/>
<a href="javascript:;void(0);" id="buttonOne">Insert input form</a>
<hr/>
<input type="submit" value="Post the form" />
</form>
<script type="text/javascript">
var sequence = 0;
$(document).ready(function(){
$("#buttonOne").click(function(){
$("form").prepend("<input name=name"+sequence+" placeholder='something' type='text' /> <br/> ");
sequence++;
});
$("form").submit(function(e){
$('input[type=text]').each(function(){
if($(this).val() == "") $(this).remove();
});
if( $('input[type=text]').size() >= 2 ){
random_number = parseInt( Math.random() * $('input[type=text]').size() );
alert( $('input[type=text]:eq('+random_number+')').val() );
}else{
alert("sorry you need at least 2 fields");
}
return false;
});
});
</script>
Thanks a lot for helping me out!
Aucun commentaire:
Enregistrer un commentaire