I have a jquery mobile project and I have three buttons grouped horizontally. When the far left or far right button are clicked the text in the middle button increases or decreases. When I try to submit the text as an int to MySQL database through php, I get the value 0 inserted into the field. Obviously #seatCounter2 is not getting a value. How can I get the value of #seatCounter2?
Any help/advice would be appreciated.
<fieldset class="ui-grid-a" style="margin-removed10px" >
<label for="name" class="ui-block-a" date-inline="true" style="margin-top:5px">Seats Available</label>
<div data-role="controlgroup" data-type="horizontal" date-inline="true" class="ui-block-b" >
<a id="seatIncrease" data-role="button" style="width:2.8em" data-theme="c">+</a>
<a href="#" id="seatCounter" data-role="button" style="width:50px; height:39px" data-theme="b"><span id="seatCounter2" name="seatCounter2" style="margin-removed10px, padding-removed35px">1</span></a>
<a id="seatDecrease" data-role="button" style="width:2.8em" data-theme="c">-</a>
</div>
</fieldset>
$(function(){
$("#seatIncrease").click(function(){
$("#seatCounter2").text( Number($("#seatCounter2").text()) + 1 );
});
$("#seatDecrease").click(function(){
$("#seatCounter2").text( Math.max(1, Number($("#seatCounter2").text()) - 1) );
});
});
$seatcounter = intval($_POST['seatCounter2']);
if ($canSubmitForm)
{
if ($isFormEmpty == false)
{
require_once('database.php');
$query = "INSERT INTO journey
(from_destination,to_destination,journey_type,depart_date,depart_time,return_date,return_time,seats_available,journey_message,user_type)
VALUES('$pjFrom','$pjTo','$radioJourneyType', STR_TO_DATE('$departDate','%d/%m/%Y'),'$newDepTime',STR_TO_DATE('$returnDate','%d/%m/%Y'),'$newRetTime ','$seatcounter','$textareanotes','$radUserType')";
$db->exec($query);
include('index.php');
}
}
else
{
$error = "Invalid product data. Check all fields and try again.";
include('error.php');
}