ازاي احل التاسك ده؟؟

31 views
Skip to first unread message

jack jack

unread,
Mar 10, 2013, 1:54:24 PM3/10/13
to arabc...@googlegroups.com
عندي 2 checkbox
كل واحد بقيمة
الاول 5
والتاني 10
والمجموع الكلي 10
فعاوز لما اعلم ع الشيكبوكس الاول
يتم اضافة 5 ع ال 
10
وهكذا

Emad Elsaid

unread,
Mar 10, 2013, 2:02:22 PM3/10/13
to arabc...@googlegroups.com
هل المجموع الكلى ده عبارة عن متغير فى الجافاسكريت ؟ و عاوز لما تختار واحد من التشيكبوكس يزود عليه ؟
لو كده يبقى  ممكن تستخدم الجى كويرى
var score = 10;
$('#checkbox_id').change(function(){
 $this = this;
 if($this.attr('checked')=='checked'){
   score += 5;
  }else{
    score -= 5;
  }
});
ده على حسب فهمى للمشكلة

jack jack

unread,
Mar 10, 2013, 2:08:28 PM3/10/13
to arabc...@googlegroups.com
متغير عادي مش في الجافاسكربت
$all = 10;

Emad Elsaid

unread,
Mar 10, 2013, 2:10:47 PM3/10/13
to arabc...@googlegroups.com
اه فهمتك انت عاوز لما يتبعت للسيرفر تجمعه على متتغير بى اتش بى ؟
طيب انت نسيت تقوللى انت بتبعت بPOST or GET
$all = 10;
if(isset($_GET['checkbox5_name'])){
 $all += 5;
}

Mohamed Elzainy

unread,
Mar 10, 2013, 2:35:44 PM3/10/13
to arabc...@googlegroups.com

شرح المشكلة باختصار

Emad Elsaid

unread,
Mar 10, 2013, 2:42:09 PM3/10/13
to arabc...@googlegroups.com
كل ده بالجافاسكريبت
اول حاجة اعمل متغير
var total = 10;
و دالة تعمل ابديت للمكان اللى بيظهر فيه التوتال
function update_total(){
  $('#total_id').html(total+'$');
}

وبعدين اعمل دالة تزود و دالة تقلل فيه
function total_increase(amount){
 total += amount;
 update();
}

function total_decrease(amount){
 total -= amount;
 update();
}

و بعدين اربط بقى مع كل تيك بوكس
$(function(){
  $('#checkbox_id').change(function(){
   if($(this).attr('checked')=='checked'){
    total_increase(5);
  }else{
    total_decrease(5);
  }
  });
});

خلى بالك تغير السيليكتورز زى
#checkbox_id
#total_id
بقيم الid الخاصة بيك

Mohamed Elzainy

unread,
Mar 10, 2013, 2:48:50 PM3/10/13
to arabc...@googlegroups.com
شرح رااائع
شكرا

Emad Elsaid

unread,
Mar 10, 2013, 2:50:04 PM3/10/13
to arabc...@googlegroups.com
الحمد لله كده تمام اتحلت يعنى ؟ :)

Mohamed Elzainy

unread,
Mar 10, 2013, 3:07:16 PM3/10/13
to arabc...@googlegroups.com
هجرب واشوف
Reply all
Reply to author
Forward
0 new messages