I'm trying to get the selected value of two radio buttons by posting via jQuery and processing it in PHP. Here's my code:
HTML:
<input type="radio" name="purch" value="goods" checked>Goods<br>
<input type="radio" name="purch" value="services">Services
jQuery:
$("#addDoc").click(function(){
$.post("manual.php",
{
invoice: $("#invoiceBox").val(),
supplierName: $("#supplierBox").val(),
refNo: $("#refBox").val(),
vatReg: $("#vregBox").val(),
vatPurch: $('input[name=purch]:checked', '#addForm').val()
},
function(data){
alert(data);
});
});
PHP:
<?php
$vatPurch = $_POST['vatPurch'];
echo $vatPurch;
?>
However I try to post it, I always get an 'Notice: Undefined index: vatPurch' error when submitting the form.