Checked with validator and it showed no error in this script.
The alert is not working too. and showing no error, looks that the
script is not running at all.
below is the complete code.
<div id="content-header">
<%= show_header_icon %>
<h1><%= t('admission') %></h1>
<div class='header-sep'>|</div>
<div class='sub-header'><%= t('previous_details') %></div>
</div>
<div id="page-yield">
<div class="bread_crumb">
<% breadcrumb :student_previous_data, @student %>
<%= render_breadcrumbs %>
</div>
<script>
$(function() {
$("#total_mark").keyup(function() {
alert("key pressed");
var t = $("#total_mark").val();
var o = $("#ob_marks").val();
$("#percentage").val(o * 100 / t);
})
});
</script>
<% unless flash[:notice].nil? %>
<p class="flash-msg"> <%= flash[:notice] %> </p>
<% end %>
<%= error_messages_for 'previous_data' %>
<% form_for :student_previous_details do |a| %>
<%#= error_messages_for 'employee_bank_details' %>
<span class="span-sub-heading"><%= t('previous_educational_details')
%></span>
<hr class="sub-heading"></hr>
<div id="form-contents">
<%= a.hidden_field :student_id, :value => @student.id %>
<div class="label-field-pair">
<label><%= t('institution_name') %></label>
<div class="text-input-bg"><%= a.text_field :institution
%></div>
<div class="extender"></div>
</div>
<div class="label-field-pair">
<label><%= t('board_name') %></label>
<div class="text-input-bg"><%= a.text_field :board_name %></div>
<div class="extender"></div>
</div>
<div class="label-field-pair">
<label><%= t('board_roll_num') %></label>
<div class="text-input-bg"><%= a.text_field :board_roll_num
%></div>
<div class="extender"></div>
</div>
<div class="label-field-pair">
<label><%= t('course_text') %></label>
<div class="text-input-bg"><%= a.text_field :course %></div>
<div class="extender"></div>
</div>
<div class="label-field-pair">
<label><%= t('group_name') %></label>
<div class="text-input-bg"><%= a.text_field :group_name %></div>
<div class="extender"></div>
</div>
<div class="label-field-pair">
<label><%= t('year') %></label>
<div class="text-input-bg"><%= a.text_field :year %></div>
<div class="extender"></div>
</div>
<div class="label-field-pair">
<label><%= t('obtained_marks') %></label>
<div class="text-input-bg"><%= a.text_field :ob_marks, :id =>
"ob_marks" %></div>
<div class="extender"></div>
</div>
<div class="label-field-pair">
<label><%= t('total_mark') %></label>
<div class="text-input-bg"><%= a.text_field :total_mark, :id =>
"total_mark" %></div>
<div class="extender"></div>
<div class="label-field-pair">
<label><%= t('percentage_marks') %></label>
<div class="text-input-bg"><%= a.text_field :percentage, :id =>
"percentage" %></div>
<div class="extender"></div>
</div>
<div class="label-field-pair">
<label for="student_blood_group"><%= t('exam') %></label>
<div class="text-input-bg"><%= select :student_previous_datas,
:exam, ["Annual", "Supply"] %></div>
</div>
<div class="extender"></div>
</div>
<div class="save-proceed-button">
<%= link_to "► #{t('skip')}", {:controller => "student", :action
=> "admission4", :id => @student.id },:class=>'user_button' %>
<%= submit_tag "► #{t('save_and_proceed')}", :disable_with => "►
#{t('please_wait')}" %>
</div>
</div>
<% end %>
<div class="ajax-subject">
<ul id="added-subjects">
<% unless @previous_subject.nil? %>
<% @previous_subject.each do |p| %>
<li><div class="name"><%= p.subject %></div>
<div class="themed_text val"><span>:</span><%= p.mark
%></div>
<div class="delete"><%= link_to_remote
image_tag("/images/buttons/delete-new.png", :border => 0),
:url => {:action => "delete_previous_subject", :id =>
p.id},
:loading=>"$('loader').show();"
,:loaded=>"$('loader').hide();",
:update => "added_subjects"%></div>
</li>
<% end %>
<% end %>
</ul>
<%= link_to_remote "#{t('add_subject')}",
:url=>{:controller=>"student",:action=>"previous_subject",
:id=>@student.id},:loading=>"$('loader').show();"
,:loaded=>"$('loader').hide();"%>
<%= image_tag("loader.gif", :align => "absmiddle", :border => 0, :id
=> "loader", :style =>"display: none;" ) %>
<div id="subject">
</div>
</div>
</div>