How can i change a php variable with a onclick event???
Posted: Thu Mar 18, 2010 3:52 am
I have a form with an AJAX call that adds the $_SESSION['batcharray'] to a data base and that all works great.
This is triggered with the onclick event of a button.
What I need is to unset $_SESSION['batcharray'] once this is done.
But only when the onclick event happens.
So since im brand new, i figured the only way to do this is to change a php variable called $brty->_mycheck to 1 from 0, when the onclick event happens.
Im planning to have a function in a class like this that will test $brty->_mycheck and empty $_SESSION['batcharray'] if it is 1, then reset $brty->_mycheck back to 0 so it doesn't happen i do a new Submit wich does other things. Is this the right approach?? Here is the Function any pointers would be great im lost
Thanks in advance
Code: Select all
<?php
public function unSetBatch()
{
var_dump($this->_mycheck);
if ($this->_mycheck = 1)
{
unset($_SESSION['batcharray']);
$this->_mycheck = 0;
var_dump($this->_mycheck);
}
}
?>
this is the button It works fine, but I haven't any idear how to change a Varible from a onclick![]()
Code: Select all
<?php $form->add( array('name' => 'arrayclear', 'type' => 'button', 'buttontype' => 'button','name' => 'Clear_array' ,'value' => 'Clear array', 'onclick'=> 'addDatadb();' ) );
?>