Question

I created an jquery to know if the item number im typing is valid or not if valid there's a text will say that it is valid and the user will type how many of the said item will order after that automatically it will show the item description, price per unit and the total price for it (item price*quantity)

my problem is. how can i save it to my database after filling up the form when i declare $unit_price = $_POST['unitprice'];

it has an error of undefined index. here is my code

here is my script

        $('#feedback3').load('itemlist.php').show();

    $('#stock_input').keyup(function(){
    $.post('itemlist.php', { stock_number: form.stock_number.value }, 
        function(result) {
            $('#feedback3').html(result.message).show();

            displayTotal(result.price);


    }, 'json');
    });

    $('#quantity').keyup(function(){
    $.post('itemlist.php', { stock_number: form.stock_number.value }, 
        function(result) {
            $('#feedback3').html(result.message).show();
            $('#itemdesc').html(result.desc).show();
            $('#unitprice').html(result.price).show();
            displayTotal(result.price);




    }, 'json');

    }); 
});

Here is my input types but the result is undefined index

    <tr>
        <td><text class="normal">Item Number: </text></td> 
        <td><input type="text" class="input" name="stock_number" id="stock_input" > <text id="feedback3"></text></td>
    </tr>
    <tr>
        <td><text class="normal">Unit price : </text></td> 
        <td><span>   $ </span><text id='unitprice' name="unit_price"></text></td>
    </tr>
    <tr>
        <td><text class="normal">Description : </text></td> 
        <td><span id='itemdesc' name='desc'></span></td>
    </tr>
    <tr>
        <td><text class="normal">Quantity: </text></td> 
        <td><input type="text" class="input" name="quantity" id="quantity" ><text id="feedback4"></text></td>
    </tr>
    <tr>
        <td><text class="normal">Size : </text></td> 
        <td><input type="text" class="input" name="size"</td>
    </tr>
    <tr>
        <td><text class="normal">Customize Information : </text></td> 
        <td><textarea cols="40" rows="4" name="custom"> </textarea></td>
    </tr>
    <tr>
        <td><text class="normal">Total Price : </text></td> 
        <td> <span>   $ </span><span id='totalPrice' name='total'></span></td>
    </tr>
</table></fieldset><br>

and what im trying to do is

    if(isset($_POST['submit'];)){
   $unitprice = $_POST['unit_price']; 
    }
//and so on my other input types

thank you

No correct solution

OTHER TIPS

I don't think you have $_POST['submit'] when using jquery/ajax. Try entering that in the php file

print_r($_POST);die;

And see what you get...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top