Hello,
I want to calculate percentage marks of students using jquery, for this
I tried the below code but its not working. I am very beginner in ruby
on rails.
<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>
<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>
<script type="text/javascript">
$(function() {
$("#total_mark, #ob_marks").keyup(function() {
var t = $("#total_mark").val();
var o = $("#ob_marks").val();
$("#percentage").val(o * 100 / t);
})
});
</script>
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/526d0bcd748e6d8ecf29d1d91147a0a0%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment