onclick() event works well, how to make the radio button be selected in page after use onclick()?

angel_lee 2006-09-20 05:17:04
Question1: I used onclick() event in the radio button.

<label><input type="radio" id="r_1" onclick="return SelectTab('tab_1');" name="srhType" value="EXACT" />Exact</label>
<label><input type="radio" id="r_2" onclick="return SelectTab('tab_2');" name="srhType" value="ALL" />All</label>

onclick() event works well, but the radio button could not be selected in page after use onclick().

How to make the radio button be selected in page and do not give up onclick() event?



Question2: I have pageA and pageB. New page will be opened in pageA after I click the link in pageB. But the focus still on pageB althrough pageA is refresh.

How to get the focus in pageA when open the new page in pageA?

Thanks a lot!

...全文
235 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
angel_lee 2006-09-20
  • 打赏
  • 举报
回复
I solved the first question. :)

Just change onclick="return SelectTab('tab_1');"
to onclick="SelectTab('tab_1');"

Get rid of the "return" works well.

Thanks net_lover(【孟子E章】) !
angel_lee 2006-09-20
  • 打赏
  • 举报
回复
Q1:

I can get the selected value of radio. But the radio button looks didn't be selected in page. None of the circle that shows which radio be selected is selected.

Does I make sense?
angel_lee 2006-09-20
  • 打赏
  • 举报
回复
Thanks so much, net_lover(【孟子E章】) !

I've tried the codes as you showed to me. Both question1 and question2 did not work.

Do you have any good idea?
孟子E章 2006-09-20
  • 打赏
  • 举报
回复
<label><input type="radio" id="r_1" onclick="return SelectTab('tab_1');" name="srhType" value="EXACT" />Exact</label>
<label><input type="radio" id="r_2" onclick="return SelectTab('tab_2');" name="srhType" value="ALL" />All</label>
<script>
r_11 = r_21 = true
function SelectTab(x)
{
eval(event.srcElement.id + ".checked=" + event.srcElement.id + "1")
eval(event.srcElement.id + "1=!" + event.srcElement.id + "1")
}
</script>
孟子E章 2006-09-20
  • 打赏
  • 举报
回复
<label><input type="radio" id="r_1" onclick="return SelectTab('tab_1',this);" name="srhType" value="EXACT" />Exact</label>
<label><input type="radio" id="r_2" onclick="return SelectTab('tab_2',this);" name="srhType" value="ALL" />All</label>
<script>
r_11 = r_21 = true
function SelectTab(x,o)
{
eval(o.id + ".checked=" + o.id + "1")
eval(o.id + "1=!" + o.id + "1")
}
</script>
孟子E章 2006-09-20
  • 打赏
  • 举报
回复
<script>
var bln = true
function SelectTab(x)
{
r_1.checked=bln
bln=!bln
}
</script>

in the code ,i just handle the first radio ,other radio is just like the first
孟子E章 2006-09-20
  • 打赏
  • 举报
回复
Q1:
<label><input type="radio" id="r_1" onclick="return SelectTab('tab_1');" name="srhType" value="EXACT" />Exact</label>
<label><input type="radio" id="r_2" onclick="return SelectTab('tab_2');" name="srhType" value="ALL" />All</label>
<script>
var bln = true
function SelectTab(x)
{
r_1.checked=bln
bln=!bln
}
</script>


Q2:

<body onload="self.focus()">


BTW: more than radios should be the same name attribute
angel_lee 2006-09-20
  • 打赏
  • 举报
回复
For question2, my link control in pageB is <asp:HyperLink .../> , could not use onclick() event.

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧