SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict kuldeepkaundal's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    calling a javascript function on focus og input box in cakephp

    Hi,

    I just wanted to know is there a way to achieve something like the in cakephp:

    <input name="sugbox" onfocus="ClearForm();" type="text" id="sugbox" class="searchbox11" value="type name here" />

    I am trying following:

    <?php echo $form->input('Sugname.sugname', array( 'type' => 'text' , 'label' => '' , 'id' => 'sugname' ,'class' => 'searchbox11' ,'value' => 'type name here', 'onfocus'=> "ClearForm();" )); ?>

    everything goes fine, but, m unable to call that function.

    Plz suggest a solution for this.
    Thanks in advance,
    kul.

  2. #2
    SitePoint Enthusiast toytron's Avatar
    Join Date
    Nov 2006
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I know, you can't call a javascript function with php.
    You could write a javascript that triggers on pageload or when the dom is ready.
    I know prototype has a way to do this. You can observe if the page is loaded and then use "fire" to start an event. Php could echo this piece of javascript in your page.

  3. #3
    SitePoint Addict kuldeepkaundal's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nops,

    Its doable, n i've done this, the issue was that i was passing wrong id.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •