/    Sign up×
Community /Pin to ProfileBookmark

Radio Button

All I am attempting to do is turn a slide show on or off.

In the head I have

[code]
<script language=”JavaScript”>
function GetSelectedItem() {

chosen = “”
len = document.f1.r1.length

for (i = 0; i <len; i++) {
if (document.f1.r1[i].checked) {
chosen = document.f1.r1[i].value
}

}

if (chosen == “Off”) {
javascript:void(disableSlideMode());
}
else {
javascript:void(enableSlideMode(10));
}
}
</script>

In the body I have

<form NAME = f1>

<p align=”center”>
<input type = radio Name = r1 Value = “On” onClick =GetSelectedItem()>
On
<input type = radio Name = r1 Value = “Off” onClick =GetSelectedItem()>
Off
</p>

</form>
[/code]

This works but the problem is that the selected button clears and I do not want it to clear. If it clears then the user does not know if the show is on or off. If I use just an alert to tell which button is checked then they do not clear, but if I put in the code to enable or disable the slide show then the buttons clear. How can I keep the buttons from clearing?

Thank You For Any Help
Bungo

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorMar 07.2008 — I don't see how your selected button "clears". And you should code in standard mode: always quote the HTML attributes with double quotes, use lowercase for HTML tags, use [B]type="text/javascript" [/B]instead of [B]language="JavaScript"[/B], use local variables in your javascript codes if you don't need (and you don't, in your example) them to be global.
Copy linkTweet thisAlerts:
@BungoauthorMar 07.2008 — Thanks for the reply..

Here is the URL


Test it and you will see the buttons clear.
×

Success!

Help @Bungo 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.5,
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,
)...