PHP input form javascript integration failed
Posted: Fri Jan 20, 2012 1:20 pm
I have this input box wrapped in php code. (I've only pasted the portion of that php code.)
And I would like to add this javascript into the input form
I tried this and got a syntax error
Someone suggested to me that I should be using $html plus slashes to accomplish this, but I dont think thats right, because the onfocus and onblur should be inside the input tags.
Any help appreciated
Thanks in advance
Code: Select all
<?php
case 'email':
$html .= '
<input name="s" id="s" value="Email..." type="text" size="18" value="'.esc_html($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input"/>';
break;
?>Code: Select all
onfocus="if (this.value == 'Search...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search...';}Code: Select all
<input name="s" id="s" onfocus="'.if (this.value == 'Search...') {this.value = '';}.'" onblur="'.if (this.value == '') {this.value = 'Search...';}.'" value="Email..." type="text" size="18" value="'.esc_html($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input"/>';Any help appreciated
Thanks in advance