开发者

PHP result display in textbox onClick

开发者 https://www.devze.com 2023-03-18 03:35 出处:网络
I need to get result where PHP generated ID for current button click is displayed in html textfield...

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

精彩评论

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