Ajaxly set Text Field Value with Drupal Forms API
I suggest you instead of creating link and try to call ajax with old method( call form your custom js file ) try  drupal ajax method

My suggestion is : 

function yourmodule_form_alter(&amp;$form,$form_state,$form_id){
if($form_id=='your specified form name '){
$form['id_number'] = array(
    '#title' =&gt; t('ID Number'),
    '#type' =&gt; 'textfield',  //textfield  
     '#prefix' =&gt; '&lt;div id="vm-container"&gt;',    
    '#suffix' =&gt; '&lt;/div&gt;'
    '#attributes' =&gt; array('id' =&gt; 'myid_search_id_number'),
 );
$form['myajax'] = array(
        '#type' =&gt;'button',
        '#value' =&gt; t('fill me'),
        '#ajax' =&gt; array(
            'callback' =&gt; '_myfuction_fill_number_ajax',
            'wrapper' =&gt; 'vm-container',
            'method' =&gt; 'replace',
            'effect' =&gt; 'fade',
            'prevent'=&gt; 'sumbmit',
        ),
    );
 }
}
function _myfuction_fill_number_ajax(&amp;$form,$form_state){
     $form['id_number'] ['#default_value'] = myid_some_function(); 
    // if not work try it with  $form['id_number'] ['#value'] = myid_some_function(); 
      return $form;
    }


also if you can want do ajax with jquery, add js file to your form, in that js file  set click handler for your link (  tag) and in click  call $.ajax with you menu rout.