php - execute a function when a link is clicked -


basically want have link inside div when clicked display <form>

<sidebar>   <h2>title</h2>   <a href="display.php"> display </a>   <hr>    //display here   </sidebar> 

display.php

function display() {  $test = echo '<input type="text" name="text">'; return  } 

the logic goes like, if clicked href="display.php" display function display();

how can display returned value in display() function below <hr>

i cant seem figure our correct logic it,

<hr> if (display() == true) {      $test = echo '<input type="text" name="text">'; return } 

you cannot that, need submit request server in order process , echo, here way doing won't work, either use form or link parameter(if using get method) or post method, , using $_get or $_post, can execute function.

also function wrong, cannot write echo that, should be

function display() {     $test = '<input type="text" name="text">';     return $test; } 

for example

if using get link parameter sufficient, say

<a href="display.php?display=true"> display </a>  <?php    if(!empty($_get['true'])) {       echo display();    } ?> 

alternatively if want use post method you'll need form specified before

<form method="post">    <input type="submit" value="display" name="display" /> </form>  <?php    if(!empty($_post['display'])) {       echo display();    } ?> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -