Click here to Skip to main content
14,693,130 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one label and button. when i click button, i need display button value into label    
in same page without page reload in php

What I have tried:

$(function (){
$(".1234").click(function() {
var CID = $(this).val();

type: "POST",
url: "php/test.php",
 success: function(data){
in test.php;
$id = $_REQUEST["C_ID"];
but i can't get the button value 
Updated 24-Nov-19 20:38pm

Why do you want to make a round trip to the server just to copy the button value to a label on the same page, can't you just do it with JavaScript or jQuery?
However,, if you insist:
success: function(data){
is missing a closing

I wonder why this
You did not show your html code, make sure you button look similar to this:
<button class="1234" value="The button value that you want">click me</button>
In the test.php,
	if (isset($_REQUEST["C_ID"]))
   		echo $_REQUEST["C_ID"];

Last but not least, you can achieve the same objective using just jQuery:
<!doctype html>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src=""></script>
  $(".1234").click(function() {




<button class="1234" value="Hello, Button!">click me</button>

Nataraj Pandiyan 10-Feb-17 11:57am
Tthank you Peter Leow,but how to get that label value in php?
Peter Leow 10-Feb-17 19:57pm
similar to sending the button value to the server, but this time use text() to get the value in jQuery first before Ajaxing.
If seems that you are familiar with jQuery and PHP, then google and learn.
type: 'post',
dataType: 'json',
data: {id: testId},//Pass the id

`if(isset($_POST['id']) ){
$te = $_POST['id'];
echo $te;


echo $te;

CHill60 25-Nov-19 6:42am
An unformatted, unexplained code dump is not a solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900