---
title: "Values of variables to add in an array after I click the submit button?"  
description: "Values of variables to add in an array after I click the submit button?"  
author: "Anonymous User"  
published: 2013-10-22  
updated: 2013-10-22  
canonical: https://www.mindstick.com/forum/1699/values-of-variables-to-add-in-an-array-after-i-click-the-submit-button  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# Values of variables to add in an array after I click the submit button?

Placed a [value in an array](https://www.mindstick.com/forum/12826/how-do-i-write-a-method-to-determine-the-highest-value-in-an-array) [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation) after clicking [submit button](https://www.mindstick.com/forum/12834/make-text-appear-when-submit-button-clicked-and-checkbox-is-unchecked) and the submit button will the one to [trigger](https://www.mindstick.com/blog/167/triggers-in-wpf) the arrayholder.push().

[Variables](https://www.mindstick.com/articles/715/php-variables) that should be added to the array are those buttons that is clicked.

**[JAVASCRIPT](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-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](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) 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" />
```

## Replies

### Reply by Samuel Fernandes

Instead of "submit" type, change into "[button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net)" type and then use below line of code:

```
<html><head>    <script type="text/javascript">        function
pushMe() {            arrayholder.push(val1);             document.getElementById("form1").submit();        }    </script></head><body>    <form id="form1">    <input id="btnPushMe" type="button" click="pushMe" />    </form></body></html>
```


---

Original Source: https://www.mindstick.com/forum/1699/values-of-variables-to-add-in-an-array-after-i-click-the-submit-button

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
