Nothing happens because nothing is selected and your snippet returns
void which == false
On Mar 19, 3:47 am, Sijo Kg
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hi
>
> I have a form
>
> <%= form_remote_tag :url => { :action =>
''sd_resolution_save'',
> :id => @sd_ticket.id, },%>
>
> <table >
> <tr>
> <th width=""><label for="" >Resolution
Code</label></th>
> <td width=""><%= select( "sd_resolution",
> "service_desk_resolution_code_id",
> ServiceDeskResolutionCode.find(:all).collect {|p| [ p.name, p.id ] })
> %></td>
> </tr>
>
> <tr>
> <th width=""><label for=""
>Effort</label></th>
>
> <td><table><tr>
>
> <th width=""><label for="" >Hr:
</label></th>
> <td><%= text_field :sd_resol, "hours",
"size" => 2 %></td>
> <th width=""><label for="" >Min:
</label></th>
> <td><%= text_field :sd_resol, "minutes",
"size" => 2 %></td>
>
> </tr></table></td>
>
> </tr>
> </table>
> <table>
> <tr>
> <td>
>
> <button type="submit" value="save"
onclick="return
>
checkResolution(document.getElementById(''sd_resolution_service_desk_resolut
ion_code_id''),document.getElementById(''sd_resol_days''),document.getElementB
yId(''sd_resol_hours''),document.getElementById(''sd_resol_minutes''),
> ''Please Choose Resolution'');">Save</button>
>
> <%= end_form_tag %>
>
> And javascript is
>
> script type="text/javascript">
>
> function checkResolution(elem,days,hours,minutes, helperMsg)
> {
>
> for (i=0;i<elem.length;i++)
> {
> if (elem.options[i].selected){
> if( elem.options[i].text.toLowerCase()== "<< select any
>>"){
> alert(helperMsg);
> elem.focus();
> return false;
> }
> }
> }
> //alert(days.value);
>
> }
> </script>
>
> HERE THE CHECKING HAPPENS BUT THE ALERT MESSAGE IS NOT PRINTED (For
> example if i select nothing in the select box and click ok button
> nothing happens).WHY?
>
> Sijo
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---