JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Web Design 版  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 請問要如何檢查或得知radio元件的值呢?
referto2





發文: 45
積分: 0
於 2005-03-02 16:19 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
value對它好像是無效的.......急問...

謝謝


reply to postreply to post
Passion has no reason
作者 Re:請問要如何檢查或得知radio元件的值呢? [Re:referto2]
yupin





發文: 343
積分: 1
於 2005-03-02 17:01 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
試試以下的程式:

<html>
<head>
<script>
  function getValue(){
    for(i=0; i<frm.xxx.length; i++){
      if(frm.xxx[i].checked){
        alert(frm.xxx[i].value);
        break;
      }
    }
  }
</script>
</head>
<body>
<form name='frm'>
  <input type='radio' name='xxx' value='1'>item 1<br>
  <input type='radio' name='xxx' value='2'>item 2<br>
  <input type='radio' name='xxx' value='3'>item 3<br>
  <input type='radio' name='xxx' value='4'>item 4<br>
  <input type='radio' name='xxx' value='5'>item 5<br>
  <input type='button' value='Get Value' onclick='javascript:getValue()'>
</form>
</body>
</html>


reply to postreply to post
作者 Re:請問要如何檢查或得知radio元件的值呢? [Re:referto2]
abgne





發文: 323
積分: 2
於 2005-03-10 15:01 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
try it!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
function show(r){
    alert(document.getElementById(r.id).value);
}
</script>
</HEAD>
 
<BODY>
<FORM METHOD=POST ACTION="" name="form1">
<INPUT TYPE="radio" id="r1" value="1" onClick="show(this);">1
<INPUT TYPE="radio" id="r2" value="2" onClick="show(this);">2
</FORM>
</BODY>
</HTML>


reply to postreply to post
» JWorld@TW »  Web Design 版

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8