Can we call a php function on html buttons onClick event? if yes, how? i really had a hard time solving this.here is my code:

<?php
function store_func($param){

//some code here

}
?>

...
<?php
...
	echo '<td> <input name="edit" type="submit" id="edit" value="EDIT" onClick="store_func($param);"/></td></tr>';
...	
?>

it doesnt execute the code inside the php function. pls help me.thanks in advance.

The php function can be called, but you'll need some javascript to send and recieve the xmlhttprequest (AJAX).

We do this kind of thing all the time, using either Ajax or javascript depending on what is needed. Perhaps its best you describe exactly what you wish to happen when the button is clicked.


Matti Ressler
Suomedia

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.