Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML PHP MySQL jQuery
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>	
 
// Seat available Counter
$(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']);
 
//will only get executed if true
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');
}
Posted 28-Mar-13 4:39am

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



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100