开发者

PHP result display in textbox onClick

I need to get result where PHP generated ID for current button click is displayed in html textfield...

Is there any easy way of doing this?

开发者_如何学运维

This is the link of what I am trying to do http://dtech.id.lv/lat.php When user first comes he doesn't have code, so he clicks get code. I need that php generated code is pasted in textbox after this click...

Could someone help? Thank you!


Button clicked, something shows in the text field. Sometimes Javascript isn't necessary.

<?php
$code = "";
if (isset($_POST['buttonId']))
{
    $code = 'Some code here';   
}
?>
<form method="post" >
    <input name="textField" id="textField" type="text" value="<?php echo $code; ?>" />
    <input name="buttonId" id="buttonId" type="submit" value="Submit" />
</form>


Assuming your html looks like this:

<button id="myPHPid">...</button>
<input type="text" id="idRecipient" />

then

<button id="myPHPid" onclick="document.getElementById('idRecipient').value = this.id">...</button>


try this code

$('button').live('click',function() {
    var $butVal= $(this).val();
    alert($butVal);
    $('input#buttonValue').val($butVal);
    return false;
});

live DEMO

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜