Is it possible to set a button's onclick action to a javascript variable? The idea is that we are controlling a table with javascript. Whenever one clicks on a row of that table, we update a javascript variable. That var would be the _GET var for the php script to be run.
asked Jan 13, 2010 at 13:29
Sakamoto Kazuma
2,5797 gold badges38 silver badges77 bronze badges
2 Answers 2
Add this to the element you want to be clickable :
onclick="setAVariable()"
And then add this javascript function in a php file :
function setAVariable(){
//dostuff
var get = "<?php echo _GET ?>" ;
}
answered Jan 13, 2010 at 13:32
marcgg
66.8k53 gold badges183 silver badges238 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
myTr.onclick = function () {
// Make sure you have a keyboard focusable and a non-JS alternative!
document.forms.myform.elements.myhiddeninput.value = someValue;
}
answered Jan 13, 2010 at 13:32
Quentin
949k137 gold badges1.3k silver badges1.4k bronze badges
Comments
lang-js