QCodo JavaScriptAction
May 11th, 2009
No comments
I propose a solution which applied in my draft QCodo. When clicking with the mouse in the TextBox is caused QJavaScriptAction event, which performs a separate javascript function. Function to clear the text content in TextBox.
This is the code in a php script QCodo:
//........................
$this->txtSearch = new QTextBox($this);
$this->txtSearch->Width = '160px';
$this->txtSearch->Text = 'претърсване ...';
$str = $this->txtSearch->ControlId;
$this->txtSearch->AddAction(new QClickEvent(), new QJavaScriptAction("txtSearchClick('$str');"));
//.......................
Row 6 is located in function QCodo, which handles event on click.
This is the javascript code in HTML portion:
<script type="text/javascript">
function txtSearchClick(str) {
document.getElementById(str).value = '';
}
</script>
Where the variable str is sent from PHP scripts. str variable contains a TextBox ControlId. It is necessary to allow the script to recognize Control, whose text removed.
For me it worked without a problem.
I use it in the Search Box on the following page:
http://avalonbg.com/products
Unique visitors to post: 0