将javascript变量设置为具有不同文本的按钮的值

I have a button thats value is set based on a mysql query in php like so:

echo "<td><button class='jsontable' onclick='Copythat(this.value)' value='" . $row['json'] . "'> " . $row['name'] . "</button></td>";

the text of the button is the name row, which works currently.

and a function that i have basically in place to try and grab the string and send it to the load function. the load function needs to receive only text of that mysql row json

function Copythat(el.val) {
var jsontoload = $(el.val).html();
load(jsontoload);
 }

If you pass this to your function, you get the context of the element where the event occurred. Once you've got that, you can pass it to jQuery and you can get the "value" attribute using the .val() shortcut method.

Note that function Copythat(el.val) { needs to be something simply like function Copythat(val) { - function parameters must be standalone variables, they cannot be written like object properties.

function Copythat(input) {
  var attrValue = $(input).val();
  alert(attrValue);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class='jsontable' onclick='Copythat(this)' value='Something'>A button</button>

You could also convert the whole thing to jQuery and ditch the inline event handler:

$(function() {
  $(".jsontable").click(function(event) {
    var attrValue = $(this).val();
    alert(attrValue);    
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class='jsontable' value='Something'>A button</button>

Or it should also be noted that for something as simple as this you don't really need jQuery at all:

function Copythat(input) {
  alert(input.value);
}
<button class='jsontable' onclick='Copythat(this)' value='Something'>A button</button>

Another further simplification if you literally only need the value to go into your function:

function Copythat(input) {
  alert(input);
}
<button class='jsontable' onclick='Copythat(this.value)' value='Something'>A button</button>

</div>