iT邦幫忙

0

C# radio button跳出相對應圖片

  • 分享至 

  • xImage

繼上一篇判讀天氣顯示圖片後...
有沒有可能用radio button 點一下更換兩種不同的圖片呢/images/emoticon/emoticon02.gif

archer9080 iT邦研究生 4 級 ‧ 2021-11-15 09:05:42 檢舉
>>>用radio button 點一下更換兩種不同的圖片

可以
YoChen iT邦研究生 1 級 ‧ 2021-11-15 11:12:11 檢舉
您可以透過Javascript檢查checked attribute或是追蹤event handler,然後去更換img的src
請問是 Web Form或 Windows Form?或是哪種情況下的radio button
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

0
海綿寶寶
iT邦大神 1 級 ‧ 2021-11-15 16:05:25
最佳解答

可能

https://ithelp.ithome.com.tw/upload/images/20211115/20001787yy0ENoeJYM.png

<img id="imageid"/><br/>
<input type="radio" id="opt1" name="rgroup" onclick="setpic(1);">
<label for="opt1">Option 1</label><br>
<input type="radio" id="opt2" name="rgroup" onclick="setpic(2);"/>
<label for="opt2">Option 2</label><br>
function setpic(x) {
	img = document.getElementById("imageid");
  
	if (x==1) {
  	img.src = "https://www.cwb.gov.tw/V8/assets/img/weather_icons/weathers/svg_icon/day/02.svg";
  }
  else if (x==2) {
  	img.src = "https://www.cwb.gov.tw/V8/assets/img/weather_icons/weathers/svg_icon/night/04.svg";
  }
}
Tsuki iT邦新手 5 級 ‧ 2021-11-18 15:18:23 檢舉

謝謝您的建議!我們已經試過這個方法但因為還有加上別的判斷條件比較複雜~已用其他方法解決

1
緯大啊緯大人
iT邦研究生 1 級 ‧ 2021-11-15 11:13:21

可以看一下這個

提問的智慧

然後更新一下你的發問~~

不然樓上 archer9080
已經回答你的問題!

Tsuki iT邦新手 5 級 ‧ 2021-11-18 15:14:42 檢舉

了解謝謝您!不好意思沒有講的很詳細~

我要發表回答

立即登入回答