Page 1 of 1
Change text for radio buttons - and for those already select
Posted: Wed Aug 15, 2012 3:46 am
by simonmlewis
Code: Select all
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Online/Offline</title>
</head>
<body>
<input type="radio" name="on/off" onclick="online();" /> Online
<br />
<input type="radio" name="on/off" onclick="offline();" /> Offline
<br />
<span id="update"></span>
<script type="text/javascript">
function online(){
document.getElementById("update").innerHTML = "Online";
}
function offline(){
document.getElementById("update").innerHTML = "Offline";
}
</script>
</body>
This script is good, but what it doesn't do, is enable the "function" to show text if a Radio Button is "selected-selected".
I have three Radios, but one is selected by default to ensure the user has at least one clicked.
But it needs to show extra info - and then to change if another Radio is selected.
So is there something small I can add to just one of these radios or the Javascrpt to do that?
Re: Change text for radio buttons - and for those already se
Posted: Wed Aug 15, 2012 4:34 am
by social_experiment
simonmlewis wrote:But it needs to show extra info - and then to change if another Radio is selected.
could you elaborate on this
Re: Change text for radio buttons - and for those already se
Posted: Wed Aug 15, 2012 4:38 am
by simonmlewis
Page opens.
Normally you select one radio button and text appears, or select another radio and that text disappears and another lots of text info appears.
I need the "selected='selected'" text (default selection) to already be showing, and then if you select another radio, that will disappear and another will show.,
Re: Change text for radio buttons - and for those already se
Posted: Wed Aug 15, 2012 4:52 am
by social_experiment
Like this ?
Code: Select all
<body>
<input type="radio" name="on/off" onclick="basic();" selected="selected" />Default
<br />
<input type="radio" name="on/off" onclick="online();" /> Online
<br />
<input type="radio" name="on/off" onclick="offline();" /> Offline
<br />
<span id="update">Basic Text</span>
<script type="text/javascript">
function online(){
document.getElementById("update").innerHTML = "Online";
}
function offline(){
document.getElementById("update").innerHTML = "Offline";
}
function basic(){
document.getElementById("update").innerHTML = "Basic Text";
}
</script>
</body>