/    Sign up×
Community /Pin to ProfileBookmark

how to apply:

how to Apply alert message on three radio buttons of the form such that when ever more than one is selected message appears.??

please help me !!

i know html of it but not the javascript !!

<html>

<head>

<title>JavaScript – Event Handling</title>
</head>

<body>

<h1>Applying event handling on the radio buttons</h1>

<form method=”POST” action=”” name=”form1″>

<input type=”radio” value=”V1″ name=”R1″>text 1</p>
<input type=”radio” value=”V2″ name=”R2″>text 2</p>
<p><input type=”radio” name=”R3″ value=”V3″>text 3</p>

</form>

</body></html>

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJul 11.2006 — Why not give all three radio buttons the same [B]name[/B] and, then, the browser won't let the visitor choose more than one radio button in that group. No JavaScript required! ?
Copy linkTweet thisAlerts:
@js2006authorJul 11.2006 — Why not give all three radio buttons the same [B]name[/B] and, then, the browser won't let the visitor choose more than one radio button in that group. No JavaScript required! ?[/QUOTE]

no can it be done without it !! i mean i like to see javascript applyied on it can you help me plz.
Copy linkTweet thisAlerts:
@phpnoviceJul 11.2006 — Not advisable. The reason is that radio buttons cannot be unchecked by clicking them again, thus, once the visitor had checked one, they would not be able to change their mind. Is that what you want?
Copy linkTweet thisAlerts:
@js2006authorJul 11.2006 — Not advisable. The reason is that radio buttons cannot be unchecked by clicking them again, thus, once the visitor had checked one, they would not be able to change their mind. Is that what you want?[/QUOTE]

i got what you say now,

but if i apply it such that ,

a table contains three forms with 9 radio buttons each form seperated with a table wall ,

now we have to apply that on each form , can it be done or not ??
Copy linkTweet thisAlerts:
@phpnoviceJul 11.2006 — Tell you what, I'll show you the code using checkboxes and then you can do what you like.
[code=html]<p><input type="checkbox" name="R1" value="V1" onclick="return OnlyOne(this, R2, R3)">text 1</p>
<p><input type="checkbox" name="R2" value="V2" onclick="return OnlyOne(this, R1, R3)">text 2</p>
<p><input type="checkbox" name="R3" value="V3" onclick="return OnlyOne(this, R1, R2)">text 3</p>[/code]

function OnlyOne(fld) {
if(fld.checked) {
var x, len = arguments.length;
for(x=1; x&lt;len; ++x) {
if(arguments[x].checked) {
alert("'" + arguments[x].value + "' is already checked.");
return false;
}
}
}
return true;
}
Copy linkTweet thisAlerts:
@js2006authorJul 11.2006 — Tell you what, I'll show you the code using checkboxes and then you can do what you like.
[code=html]<p><input type="checkbox" name="R1" value="V1" onclick="return OnlyOne(this, R2, R3)">text 1</p>
<p><input type="checkbox" name="R2" value="V2" onclick="return OnlyOne(this, R1, R3)">text 2</p>
<p><input type="checkbox" name="R3" value="V3" onclick="return OnlyOne(this, R1, R2)">text 3</p>[/code]

function OnlyOne(fld) {
if(fld.checked) {
var x, len = arguments.length;
for(x=1; x&lt;len; ++x) {
if(arguments[x].checked) {
alert("'" + arguments[x].value + "' is already checked.");
return false;
}
}
}
return true;
}
[/QUOTE]



Thankyou,

i good some idea now , please refer me a good tutorial of Event handling , any website please.
Copy linkTweet thisAlerts:
@phpnoviceJul 11.2006 — Don't know how good it is, but here is one at [URL=http://www.webreference.com/programming/javascript/diaries/]The JavaScript Diaries[/URL]:

http://www.webreference.com/programming/javascript/diaries/9/
×

Success!

Help @js2006 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...