FurkOk FurkOk - 3 months ago 14
HTML Question

How to print a html code using onclick() method via PHP?

I have this button:

<input type="submit" name="submit5" class="btn" value="Tarih ekle" onclick="tarih_alani_yap()" />


When i click it i want to add this code which is between tags. It doesnt matter how many click , if user wants to add 5 times it must be okay.

<? function tarih_alani_yap() {?>
<tr>
<td class="left" valign="top">
<label>2.Talep Edilen Tarih Aralığı: <span class="required">*</span></label>
</td>
<td class="right">
<? if ($akis_kademe == "ekle") { ?>
<input class="text" type="text" size="11" name="rezerv_bas_tarih2" id="rbt"
onclick='scwNextAction=tarih_degisti.runsAfterSCW(this); scwShow(this,event);'
value="<?= (!empty($rez_bilgi['rezerv_bas_zaman'])) ? strftime("%d %b %Y", tarih_yap($rez_bilgi['rezerv_bas_zaman'])) : '' ?>" />

<label>-</label>
<input class="text" type="text" size="11" name="rezerv_bit_tarih2" id="rbt2"
onclick='scwNextAction=tarih_kontrol.runsAfterSCW(this); scwShow(this,event);'
value="<?= (!empty($rez_bilgi['rezerv_bit_zaman'])) ? strftime("%d %b %Y", tarih_yap($rez_bilgi['rezerv_bit_zaman'])) : '' ?>" />

<? } else echo strftime("%d %b %Y %H:%M", tarih_yap($rez_bilgi['rezerv_bas_zaman'], true)) . ' - ' . strftime("%d %b %Y %H:%M", tarih_yap($rez_bilgi['rezerv_bit_zaman'], true)) ?>
</td>
</tr>


<?
}?>

Answer

You can try the following jQuery function:

$("#buttonID").click(function(){
        $("div#divID").append("<div style='color:green'>Appended text</div>");
    });

Hope it helps. =)

Comments