kerori

Wed 13 Sep 2006 10:51:44
Wed 13 Sep 2006 10:51:44
function radio_button_checker(){
var radio_choice = false;
for (counter = 0; counter < radioform.radiobutton.length; counter++)
{
if (radioform.radiobutton[counter].checked)
radio_choice = true;
}
if (!radio_choice)
{
alert ("กรุณาเลือก radio buttonก่อน!!! " )
return (false);
}
ถ้า radio มีเหลือ อันเดียว และคลิกเลือกแล้ว แต่ก็ยัง alert(message); ทำยังไงดีค่ะ
เช็คดูจาก radioform.radiobutton.length ไม่ส่งค่า 1 มาจะส่ง undefined มา
ถ้ามี radio หลายอัน ก้อเช็คได้ แต่ถ้ามีอันเดียว เช็คไม่ได้ จะแก้ยังไงดี
ลองทำการหาค่า radioform.radiobutton.length ว่าถ้ามี radio เพียงอีนเดียวมีค่าเท่าไหร่ครับ
น่าจะไม่เป็น Array ลองทำการตรวจสอบด้วย
if(radioform.radiobutton.length == "undefined")
//มี radio เพียงอันเดียว
else if(radioform.radiobutton.length > 0)
//มี radio หลายอัน
น่าจะไม่เป็น Array ลองทำการตรวจสอบด้วย
if(radioform.radiobutton.length == "undefined")
//มี radio เพียงอันเดียว
else if(radioform.radiobutton.length > 0)
//มี radio หลายอัน
kerori

Thu 14 Sep 2006 10:53:32
Thu 14 Sep 2006 10:53:32
ขอบคุณมากๆคะ

















