how to send div name with id as name and value to php on form submit without using ajax
foreach ($_SESSION['companyuser']['roles'] as $key => $value){
echo "
<div class='col-sm-3 choosecmp'>
<form action='controller/fileName.php' method='POST' id='formID'>
<div name='companyId' id='".$value['cmp_id']."'>
<div class='col-lg-12'><img src=".substr($value['company_logo'],3)." width='50px' height='50px'></div>
<div class='col-lg-12' style='min-height:50px;height:auto'>".$value['cmp_name']."</div>
<button class='btn btn-default btndefault' type='submit' name='action' value='validatecompanyid'></button>
</div>
</form>
</div>
";
}
Generating HTML code using PHP foreach
How to send the data with div id on form submit when click on div Here is my jquery code
$(".choosecmp").click(function(e){
var cmpId = this.id;
$(this).find('.btndefault').click();
// $('form#formID').submit(); // with direct form submit
});
I tried with above code to submit form using button and direct form submition. But here there is no input elements, so i want to send div id as post name and values.