views:

212

answers:

3

Hi, I am having a Html LInk created using

                <?php
      echo $html->link(
   'Save Form',
   array('action'=>'/homepage', $userid),
   array('class'=>'button','id'=>'saveForm'),
   'really save the Form ?',
   false
      );
  ?>

And i want this link to append it to #save using JQuery

How could i append this Link to an Id Using Jquery.Like the below

 $("<input id='saveForm' type='Submit' class='button' value='Save Form'>").appendTo("#fb_contentarea_col1down2 #save");

Please suggest me..

+1  A: 

If you want to use PHP to generate some HTML that you want to append using jQuery, you would need to do some AJAX. In this case using $.get() would probably be the best option. This will enable your jQuery script to get some data (the HTML to insert) through an URL. Then all you would need to do would be to process and append the data. Something like this should work.

$.get('the.url', {'optional': 'parameters'}, function(data) {
    // data will hold what was outputted by the PHP on visiting the url.
    $("selector").append(data);
});
googletorp
A: 

If I understand what you are after it would be

$('#saveForm').appendTo('#save');

That takes the saveForm element and sticks it after save element on the DOM

AutomatedTester
A: 

Your problem, I guess, is that you're not getting an id in the generated link (This is cakePHP, right?) So, I guess you'd better use the contains jQuery selector like this:

$("a:contains('Save Form')").appendTo('#saveForm');
Makram Saleh