最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - onclick with Cakephp html input - Stack Overflow

programmeradmin5浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 3

It'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' ))?>`
发布评论

评论列表(0)

  1. 暂无评论