1

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.

2 Answers 2

1

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 ?>" ;
}
Sign up to request clarification or add additional context in comments.

Comments

0
myTr.onclick = function () {
    // Make sure you have a keyboard focusable and a non-JS alternative!
    document.forms.myform.elements.myhiddeninput.value = someValue;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.