【ASP.NET】RadioButtonListをJavaScriptで操作する3

user-pic
0 Clip to Evernote



RadioButtonListをJavaScriptで操作する2に追記。

cells.lengthを用いれば、rbnidnameで指定したRadioButtonListのCountが取得できる。
またこの例は、RadioButtonListが横(Horizontal)の場合だが、縦(Vertical)の場合は、rowのCountを取ってきて同様な操作をすればよい。


function RdiobtnTest (rbnidname){
  var table = document.getElementById(rbnidname);
  var row = table.rows.item(0);
  var cellcount = row.cells.length
  var cell = row.cells.item(cellcount-1);

  if (cell.firstChild.checked) {
    alert('最後のボタンが選択されています');
  }


}
【参考】
Document Object Model HTML
http://www2u.biglobe.ne.jp/~oz-07ams/prog/dom-ref/HTML/index.html

DOMでテーブルを操作する1
http://www.yscjp.com/doc/table1.html



■関連記事


ドミノ・ピザ【PC向けサイト】 楽天トラベル株式会社 NEC Direct ・NECダイレクト