return back to the view after a javscript condition

Hi     In the view I have link_to_remote as below <%= link_to_remote( "Select", { :update=>"div_inside_transfer_reason_search_sd", :before=>"checkgroupselected($('sd_ticket_primary_assignee_group_id'));", :url =>{ :controller => 'popup', :action => 'transfer_reason',:sd_ticket=>sd_ticket,}, :with =>"'transfer_reason='+$('transfer_reason'+#{div_no}).value '&' + 'primary_group_id='+$('sd_ticket_primary_assignee_group_id').value", }) %>

in the :before i am calling the javascript to check whether the value sd_ticket_primary_assignee_group_id is empty or not..What i need is if that field is not empty only controle goes to the action transfer_reason...Otherwise that is if it is empty I have to show a hidden div..And i tried javascript like <script>     function checkgroupselected(group_id)     {         if(group_id.value==null || group_id.value=="")         {             return false;         }

    } </script>

But is not working...What may be the reason?Also is there any other method as a solution?

Thanks in advance Sijo

Hi In the view I have link_to_remote as below <%= link_to_remote( "Select", { :update=>"div_inside_transfer_reason_search_sd", :before=>"checkgroupselected($('sd_ticket_primary_assignee_group_id'));", :url =>{ :controller => 'popup', :action => 'transfer_reason',:sd_ticket=>sd_ticket,}, :with =>"'transfer_reason='+$('transfer_reason'+#{div_no}).value '&' + 'primary_group_id='+$('sd_ticket_primary_assignee_group_id').value", }) %>

in the :before i am calling the javascript to check whether the value sd_ticket_primary_assignee_group_id is empty or not..What i need is if that field is not empty only controle goes to the action transfer_reason...Otherwise that is if it is empty I have to show a hidden div..And i tried javascript like <script> function checkgroupselected(group_id) { if(group_id.value==null || group_id.value=="") { return false; }

\}

</script>

But is not working...What may be the reason?Also is there any other method as a solution?

Well you haven't said in what way is it not working: is it continuing when it shouldn't, stopping when it should continue etc... At the very least your checkgroupselected needs a return true in there, and you've got a syntax error in your :with option (missing a + before the &) and you're not using encodeURIComponent so weird stuff will happen if either of those form elements include a &

Fred