I have an html button which call a php function on click , and this function change the value of a variable , and beside the button i have a text which display the value of this variable , my question is how can i change immediatly the value and be displayed in the html page ( for example i have the current value ‘9’ , but when i click on button i want it to be ‘voila’ as done in function ) , i’ve read that i can do it with AJAX but i dont know how exactly , any help will be appreciated
The Button
<button type="button" class="btn btn-success" onClick="generer()">Generate</button>
The display input
<a href="#" class="list-group-item disabled"><?php echo $password; ?></a>
The PHP code
<?php
$password = "9";
function generer(){
$password = "voila";
}
?>
2
Answers
You can not call a php function from html. You will need javascript for that.
There are 2 possible solutions –
assuming you created generator.php file and put your generation logic in it, this will be your js function
>