Invoke JavaScript function using "onclick" in php -
this question has answer here:
- call php function javascript 5 answers
on clicking text, js function should executed.
in html:
<html> <body> <a href="#" onclick="clickthis();">table 1</a> </body> </html>
in php:
<?php require 'dbconnect.php'; function clickthis(){ $search_table = "select `table1` `booktable` `table1`='booked';" $query = mysqli_query($dbconnect,$search_table); if(mysqli_num_rows($query)==0){ "insert `booktable` (table1`) values(`booked`)"; echo'table booked successfully.'; ?>
have placed onclick
function correctly in html
?
whenever click on text table 1
, clickthis()
function should executed how can achieve result using php, javascript & html
.
p.s. i don't want use button click & dbconnect.php
external php file.
you need execute php script through ajax call. way approaching structure wrong.
you can take following steps.
- create php script , serve on
/booktable
- have
js
script fetch above url through ajax call. - bind js function onclick in html markup.
Comments
Post a Comment