怎样实现只有一个RadioButton,点击它会被选中,再次点击会取消选中?
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<script>
function uncheck()
{
var radio=document.getElementById("rad");
if (radio.tag==1){radio.checked=false;radio.tag=0;}
else{radio.checked=true;radio.tag=1;}
}
</script>
<BODY>
<input type="radio" id="rad" name="abc" onclick="uncheck();"/>
</BODY>
</HTML>
<HTML>
<script>
function uncheck()
{
var radio=document.getElementById("rad");
if (radio.tag==1){radio.checked=false;radio.tag=0;}
else{radio.checked=true;radio.tag=1;}
}
</script>
<BODY>
<input type="radio" id="rad" name="abc" onclick="uncheck();"/>
</BODY>
</HTML>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
RadioButton1.Checked=RadioButton1.Checked==True?False:True;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
RadioButton1: TRadioButton;
procedure RadioButton1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure RadioButton1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
FChek: Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.RadioButton1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
RadioButton1.Checked:=not FChek;
end;
procedure TForm1.RadioButton1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
FChek:=RadioButton1.Checked;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
RadioButton1: TRadioButton;
procedure RadioButton1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure RadioButton1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
FChek: Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.RadioButton1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
RadioButton1.Checked:=not FChek;
end;
procedure TForm1.RadioButton1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
FChek:=RadioButton1.Checked;
end;
end.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2010-05-20
展开全部
你用checkbox不就行了,用RadioButton简直是自找麻烦
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询