I need to fire a php class from a javascript function.
code:
<input type='button' name='Submit' value='Submit' class='opinionbox' onclick='verifyControl('<?=$control_no?>')'/> function verifyControl(rNo) { Cont_no=document.getElementById('ContNo').value; if(rNo==Cont_no) { frames['frame1'].print(); showPage('payment'); } else if(rNo!=Cont_no) { alert('invalid control no'); } }
i need to run the code
$data = $obj_com -> getSelectedData('tbl', 'control_no', $contno); $control_no = $contno; $obj_com -> recordPay('tbl',$contno);
inside the verifyControl() how can I do this?
You cannot ‘call’ a PHP class from Javascript because Javascript is run on the client side (ie, the browser) while PHP is run on the server. What you can do, however, is call a PHP script asynchronously, get its output, and do fun stuff with javascript. This is known as AJAX. If you’re going to go down this road, you are highly advised to use a library like jQuery and learn from there. Here are a few questions to get you started (check out the answers):