Click here to Skip to main content
15,917,645 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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>



// Seat available Counter
        $("#seatCounter2").text( Number($("#seatCounter2").text()) + 1 );
        $("#seatCounter2").text( Math.max(1, Number($("#seatCounter2").text()) - 1) );													

$seatcounter = intval($_POST['seatCounter2']);

//will only get executed if true
if ($canSubmitForm)
	if ($isFormEmpty == false)
	$query = "INSERT INTO journey
		VALUES('$pjFrom','$pjTo','$radioJourneyType', STR_TO_DATE('$departDate','%d/%m/%Y'),'$newDepTime',STR_TO_DATE('$returnDate','%d/%m/%Y'),'$newRetTime ','$seatcounter','$textareanotes','$radUserType')";
	$error = "Invalid product data. Check all fields and try again.";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900