I need help, I'm using CakePHP and its html helper. I need to select all in the input field when I click in the input field.
JavaScript:
`<script type="text/javascript">
function SelectAll(id)
{
document.getElementById(id).focus();
document.getElementById(id).select();
}
</script>`
Php:
`<?php echo $html->input('Listing/client_name', array('size' => '15','id' => 'client_name', "onclick'=>'SelectAll('client_name');", 'value'=>'Seller Name', 'class'=> 'font_display_normal' ))?>`
I need help, I'm using CakePHP and its html helper. I need to select all in the input field when I click in the input field.
JavaScript:
`<script type="text/javascript">
function SelectAll(id)
{
document.getElementById(id).focus();
document.getElementById(id).select();
}
</script>`
Php:
`<?php echo $html->input('Listing/client_name', array('size' => '15','id' => 'client_name', "onclick'=>'SelectAll('client_name');", 'value'=>'Seller Name', 'class'=> 'font_display_normal' ))?>`
Share
Improve this question
asked Aug 6, 2012 at 14:13
learner23learner23
852 gold badges4 silver badges11 bronze badges
1 Answer
Reset to default 3It's a syntax error, onclick must be a key on array.
"onclick'=>'SelectAll('client_name');"
should be:
'onclick'=> 'SelectAll("client_name");'
try:
`<?php echo $html->input('Listing/client_name', array('size' => '15','id' => 'client_name', 'onclick'=> 'SelectAll("client_name");' , 'value'=>'Seller Name', 'class'=> 'font_display_normal' ))?>`