私は学校で小さな申請をしました。あるところdropdown field。その中でdropdown私はすべてを持っており、students name4つの残りの入力フィールドもあります。ここで、入力フィールドには次のようなマークの値がmarks in physics, chemistry, mathsあり、最後のフィールドは次のようtotalになりますaddition of marks in physics+chemistry+maths.
。これで、物理学、化学、数学のajax and jquery tricks場合のように、いくつかの変更を行いました。student name will be selected from the dropdown box it will show the mark for that particular student今、私は物理学、化学、数学のマークが追加され、合計フィールドに合計されることを望んでいます。そのために私はこのようなjQueryを書きました
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#student_name').on('change',function(event){
var totalmarks = jQuery("#marks_physics").val() + jQuery("#marks_chemistry").val()+ jQuery("#marks_chemistry");
jQuery("#marks_total").val(totalmarks);
});
});
</script>
ここで、idはとstudent_nameでありdropdown field for the students name、idはが表示marks_totalされるフィールド名です。今私の問題は、それがいつその学生のを示しているかということです。という名前の2人の学生がいるとします。一度選択すると何も表示されませんが、選択すると.Iの値が表示されます。代わりに使用しましたが、そこでは機能しません。だから誰かがこれを解決する方法を教えてもらえますか?どんな助けや提案も非常に高く評価されます。前もって感謝します。total markafter additionmarksonce the name has been changed in that drop downA and BAB from the dropdownAselectchange
アップデート
実際にはそのフィールドの実際の値が表示されていますが、コンソールタブを試してみたところ、そのフィールドconsole.log(#marks_physics)の前の値が表示され、代わりにtotal前に入力された値が表示されているため、そのフィールドの値を確認しましtotal marksた。