i have 4 buttons. onclick on 3rd button i want 1st,2nd,3rd button get coloured.Similarly onclick on 4th button,i want all the buttons get coloured.And even i want to save a value when button is clicked.like when first button is clicked, a value '1' is stored in session variable.i have to pass this variable to php file.and similarly onclick on second button,a value '2' is to be stored and same for 3rd n 4th button.how can i do this?? any kind of help will be useful
<html>
<head>
<script type='text/javascript'>
function change(that){
that.style.backgroundColor = 'yellow';
document.querySelector('.button').click()
}
</script>
<style>
.button {
background-color: white;
border: 1px solid black;
color: white;
padding: 8px 30px;
text-align: center;
text-decoration: none;
display: inline-block;
cursor: pointer;
float: left;
}
</style>
<body>
<input type="button" class="button" onclick="this.style.backgroundColor = 'red';" value="1">
<input type="button" class="button" onclick="change(this)" value="2">
<input type="button" class="button" onclick="this.style.backgroundColor = 'green';" value="3">
<input type="button" class="button" onclick="this.style.backgroundColor = 'blue';" value="4">
</body>
</html>
</div>