So I have this php file where form is located.
<head>
<script src="js/create_competition.js" type="text/javascript"></script>
</head>
<body>
<form id='create-competition' action='create_competition_action.php' method='post' accept-charset='UTF-8'>
<div id="main">
<input type="button" id="addButton" value="Add" class="bt" />
</div>
<input type='submit' id='submit' name='Submit' value='Submit' />
</body>
And when you press the add button a field is created on the page. When you press it again, another field is created and so on. And when a field is created a variable in create_competition.js gets bigger by 1.
Now when lets say there is 3 field created and after that submit button is pressed I want to pass that variable (which is 3 at the moment) to create_competition_action.php so I could use the knowledge of how many fields was created there. But I have no idea how I can do that.
I tried using this in create_competition.js
$('#submit').click(function(){
alert(nrFields); // to see if works
window.location.href = "create_competition_action.php?var=" + nrFields;
})
Alert worked, after pressing submit I got an alert of how many fields was created but window.location.href did not. But other then that I have not found any good solutions on how to do it.
valuevia your script … and then let the form submit normally.