forum

Home / DeveloperSection / Forums / Values of variables to add in an array after I click the submit button?

Values of variables to add in an array after I click the submit button?

Anonymous User216722-Oct-2013

Placed a value in an array variable after clicking submit button and the submit button will the one to trigger the arrayholder.push().

Variables that should be added to the array are those buttons that is clicked.

JAVASCRIPT


<script type="text/javascript">
val1=0;
val2=0;
val3=0;
val4=0;
arrayholder=new Array();
$("#id1").click(function(){
val1=val1+1;
$("#status").html(val1);
});
$("#id2").click(function(){
val2=val2+1;
$("#status").html(val2);
});
$("#id3").click(function(){
val3=val3+1;
$("#status").html(val3);
});
$("#id4").click(function(){
val4=val4+1;
$("#status").html(val4);
});
</script>


HTML CODE

    <button id="id1">ADD Val1 FROM id1</button>
    <button id="id2">ADD Val1 FROM id2</button>
    <button id="id3">ADD Val1 FROM id3</button>
    <button id="id4">ADD Val1 FROM id4</button>
<div id="status"></div>
<input type="submit" />


Updated on 22-Oct-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By