/    Sign up×
Community /Pin to ProfileBookmark

Radios and Alert

Hi,

Is it possible to have a different alert for each radio item within a group of radios – If so how?

TIA

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@swonDec 18.2002 — Maybe you're searching for something like that:

<html>

<script language="JavaScript">

<!--

function checkit(form){

var myform = form.elements.length -1;

for(i=0;i<myform;i++)

{

if(form.elements[i].checked==false)

{

title = form.elements[i].getAttribute("title");

alert("The radio named "+ title +" isn't checked");

}

}

}

//-->

</script>

<body>

<form action="" method="post"onSubmit="return checkit(this)">

<input type="Radio" name="myradio" value="1" title=Radio1>

<input type="Radio" name="myradio" value="2" title=Radio2>

<input type="Radio" name="myradio" value="3" title=Radio3>

<input type="Submit" name="test it" value="">

</form>

</body>

</html>
Copy linkTweet thisAlerts:
@Tricky123authorDec 18.2002 — Thats very good, thanks!

Now for your next problem...

when I submit my form I want to submit a value of checked or not-checked for all the radios - so I get a value even if they were not checked.

(there can be as much useful information gained from a non-selection as for a selection!!)

Thanks!
×

Success!

Help @Tricky123 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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