/    Sign up×
Community /Pin to ProfileBookmark

JavaScript & Radio Button

Hi,

If I have 3 radio buttons

Radio Button 1
Radio Button 2
Radio Button 3

If I select radio button 2, how can I make text appear in a cell?

Thanks

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KorNov 01.2005 — something like this:
[code=php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
var txt ='some text here';
function showT(r){
var rads = document.getElementsByName(r.name);
document.getElementById('mytext').firstChild.data=(rads[1].checked)?txt:''
}
</script>
</head>
<body>
1<input name="rad" type="radio" value="1" onclick="showT(this)"><br>
2<input name="rad" type="radio" value="2" onclick="showT(this)"><br>
3<input name="rad" type="radio" value="3" onclick="showT(this)"><br>
<br>
<div id="mytext">&nbsp;</div>
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@comptech520authorNov 01.2005 — Hello, Thank you ?

It's not working. I know more about HTML and CSS than JavaScript. I have yet to take that class. The page is located at:

http://photoweb.esctonline.com/pwform.php

also is there a way to make it if you select another radio the the text to be ''

Thanks Man
Copy linkTweet thisAlerts:
@KorNov 01.2005 — 
It's not working.
[/quote]

Nope, it works.
Copy linkTweet thisAlerts:
@comptech520authorNov 01.2005 — I don't see the text that I specified
Copy linkTweet thisAlerts:
@KorNov 01.2005 — my code works. It would be very easy for u to use/adjust it. Which is your problem, after all?
Copy linkTweet thisAlerts:
@comptech520authorNov 01.2005 — This is what I have:
[code=html]
<script type="text/javascript">
var txt ='Please list the date and location of the event below.';
function showT(r){
var rads = document.getElementsByName(r.name);
document.getElementById('RadioText').firstChild.data=(rads[1].checked)?txt:''
}
</script>

<td class="alternate" colspan="5" width="500"> Are you requesting help for: <br />
<input name="m_support" type="radio" value="Help with an event" onclick="showT(this)"/>
<font color="#003399">an event you were at</font> <font size="3">
<input name="m_support" type="radio" value="Help with the test account" />
</font> <span class="style1"><font color="#003399">the test account</font></span><font size="3">
<input name="m_support" type="radio" value="General Questions" />
</font><span class="style1"><font color="#003399">general questions</font></span><font size="3"><br /><br />
<font color="#CC0000"><div id="RadioText">&nbsp;</div> </font>
</font>
[/code]
×

Success!

Help @comptech520 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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