Enjoy an ad free experience by logging in. Not a member yet?
Register .
10-09-2012, 04:58 PM
PM User |
#1
New to the CF scene
Join Date: Oct 2012
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
radio buttons refer to wrong part of program
Hello,
I am trying to build a webpage where a user answers a question (radio button) and once the answer is submitted the results of a survey of these questions is revealed. I have managed (after a long struggle) to do this for the first question. I assumed that cutting and pasting the same code and altering the ids I could add other questions. This is not the case. Answering the radio button on the second question the original answers are revealed under the first question.
I am at a total loss as why this has happened
Any help greatly appreciated
code below
[CODE]
<div class="q1">
<table width="100%">
<tbody>
<tr>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
</tr>
<tr>
<td width="20%">I need to be on my guard against others</td>
<td width="15%"align="center"> <label class="choice">
<input id="Check" name="field_Payment" type="radio" value="rarely" class="required" onclick="toggle('show');">
Rarely</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="Paypal" name="field_Payment" type="radio" value="monthly" class="required" onclick="toggle('show');">
Once a month</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="weekly" name="field_Payment" type="radio" value="weekly" class="required" onclick="toggle('show');">
Once a week</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="several" name="field_Payment" type="radio" value="several" class="required" onclick="toggle('show');">
Several times a week</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="daily" name="field_Payment" type="radio" value="daily" class="required" onclick="toggle('show');">
Once a day</label></td>
</table></td>
</tr>
<div class="q1" style="display:none" id="mytext">
<tr>
<td>
<table width="100%" border="0" cellpadding="1" cellspacing="0">
</td>
<td width="20%">Our survey said:</td>
<td width="15%" align="center"> 31%</td>
<td width="15%" align="center"> 17%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">10%</td>
</tr>
</div>
</table>
</td>
</tr>
</div>
<div class="q2">
<table width="100%">
<tbody>
<tr>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
</tr>
<tr>
<td width="20%">Negative comments about me might be being put around </td>
<td width="15%"align="center"> <label class="choice2">
<input id="Check2" name="field_Payment2" type="radio" value="rarely2" class="required" onclick="toggle('show');">
Rarely</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="Paypal2" name="field_Payment2" type="radio" value="monthly2" class="required" onclick="toggle('show');">
Once a month</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="weekly2" name="field_Payment2" type="radio" value="weekly2" class="required" onclick="toggle('show');">
Once a week</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="several2" name="field_Payment2" type="radio" value="several2" class="required" onclick="toggle('show');">
Several times a week</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="daily2" name="field_Payment2" type="radio" value="daily2" class="required" onclick="toggle('show');">
Once a day</label></td>
</table></td>
</tr>
<div class="q2" style="display:none" id="mytext">
<tr>
<td>
<table width="100%" border="0" cellpadding="1" cellspacing="0">
</td>
<td width="20%">Our survey said:</td>
<td width="15%" align="center"> 35%</td>
<td width="15%" align="center"> 24%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">14%</td>
<td width="15%" align="center">7%</td>
</tr>
</table>
</td>
</tr>
</div>
[/ICODE]
10-09-2012, 05:04 PM
PM User |
#2
Regular Coder
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 941
Thanks: 7
Thanked 95 Times in 95 Posts
After a cursory glance, the only thing I can tell you is that you have improperly nested tags. Example: an opening TABLE tag immediately before a closing TD tag.
Get that corrected, and inserted in between CODE tags, and that will help you get help.
__________________
^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com ), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
10-09-2012, 05:14 PM
PM User |
#3
New to the CF scene
Join Date: Oct 2012
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
As you can see I am very new! I have chnaged the tags... thought I did add the [CODE] tages.
Code below
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Paranoid Thoughts</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="paranoidthoughts.css" type="text/css"
media="screen" />
<script type="text/javascript">
function toggle(value){
if(value=='show') { document.getElementById('mytext').style.display='block'; }
else { document.getElementById('mytext').style.display='none'; }
}
</script>
<style type="text/css">
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<img src="paranoidimages/logos.png" alt="IoP Logo"> <br />
<img src="paranoidimages/oxfordlogo.jpg" alt="Oxford Logo">
</div>
<div id="header1">
<img src="paranoidimages/slam_logo.gif" alt="Slam Logo">
 
<img src="paranoidimages/Wellcome_Trust.jpg" alt"Wellcome logo">
</div>
<div id="parlogo">
<img alt='Paranoid thoughts' src='paranoidimages/logo.gif' border='0'/>
</div>
<div id="colortest">
</div>
<?php require_once('menu.php'); ?>
<h1>Assess your paranoia</h1>
<p>It's rare to go through life without having a paranoid thought. But how many people get these thoughts frequently?</p>
<p>We recently surveyed over a thousand people to see how many regularly had suspicious thoughts.</p>
<p>As you enter your response in the table below the results from the survey will be revealed.</p>
<p><em>Please note that this questionnaire only works in the Internet Explorer web browser.</em></p>
<h2>Paranoid thoughts questionnaire</h2>
<div class="q1">
<table width="100%">
<tbody>
<tr>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
</tr>
<tr>
<td width="20%">I need to be on my guard against others</td>
<td width="15%"align="center"> <label class="choice">
<input id="Check" name="field_Payment" type="radio" value="rarely" class="required" onclick="toggle('show');">
Rarely</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="Paypal" name="field_Payment" type="radio" value="monthly" class="required" onclick="toggle('show');">
Once a month</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="weekly" name="field_Payment" type="radio" value="weekly" class="required" onclick="toggle('show');">
Once a week</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="several" name="field_Payment" type="radio" value="several" class="required" onclick="toggle('show');">
Several times a week</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="daily" name="field_Payment" type="radio" value="daily" class="required" onclick="toggle('show');">
Once a day</label></td>
</table></td>
</tr>
<div class="q1" style="display:none" id="mytext">
<tr>
<td>
<table width="100%" border="0" cellpadding="1" cellspacing="0">
<td width="20%">Our survey said:</td>
<td width="15%" align="center"> 31%</td>
<td width="15%" align="center"> 17%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">10%</td>
</tr>
</div>
</table>
</td>
</tr>
</div>
<div class="q2">
<table width="100%">
<tbody>
<tr>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
</tr>
<tr>
<td width="20%">Negative comments about me might be being put around </td>
<td width="15%"align="center"> <label class="choice2">
<input id="Check2" name="field_Payment2" type="radio" value="rarely2" class="required" onclick="toggle('show');">
Rarely</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="Paypal2" name="field_Payment2" type="radio" value="monthly2" class="required" onclick="toggle('show');">
Once a month</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="weekly2" name="field_Payment2" type="radio" value="weekly2" class="required" onclick="toggle('show');">
Once a week</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="several2" name="field_Payment2" type="radio" value="several2" class="required" onclick="toggle('show');">
Several times a week</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="daily2" name="field_Payment2" type="radio" value="daily2" class="required" onclick="toggle('show');">
Once a day</label></td>
</table></td>
</tr>
<div class="q2" style="display:none" id="mytext">
<tr>
<td>
<table width="100%" border="0" cellpadding="1" cellspacing="0">
<td width="20%">Our survey said:</td>
<td width="15%" align="center"> 35%</td>
<td width="15%" align="center"> 24%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">14%</td>
<td width="15%" align="center">7%</td>
</tr>
</table>
</td>
</tr>
</div>
</body>
</html>
10-09-2012, 05:23 PM
PM User |
#4
Senior Coder
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
you cannot have 2 elements with the same ID - this will lead to exactly this type of problem.
try changing your my text divs to
Code:
<div class="q1" style="display:none" id="mytext1">
and
Code:
<div class="q1" style="display:none" id="mytext2">
and passing in the div id on the radio button click:
Code:
<input id="Check2" name="field_Payment2" type="radio" value="rarely2" <input id="Check" name="field_Payment" type="radio" value="rarely" class="required" onclick="toggle('show','mytext1');">
and letting your function accept that as an parameter:
Code:
function toggle(value,divid){
if(value=='show') { document.getElementById(divid).style.display='block'; }
else { document.getElementById(divid).style.display='none'; }
}
(although I can't see what the "else" is doing in the function...)
10-09-2012, 06:38 PM
PM User |
#5
Senior Coder
Join Date: Aug 2006
Location: FL
Posts: 2,763
Thanks: 29
Thanked 453 Times in 447 Posts
And you still have un-matched <table>, <tr> and <td> tag sequences.
You also should not put code between tags, like: </td> <td> and </tr> <div> ... </div> <tr>
10-09-2012, 07:24 PM
PM User |
#6
Regular Coder
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 941
Thanks: 7
Thanked 95 Times in 95 Posts
Code:
<table>
<tr>
<td></td>
</tr>
</table>
Nothing in between. Anything else is not proper HTML, exception being if you are working in a server-side dynamic language.
__________________
^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com ), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
10-09-2012, 07:36 PM
PM User |
#7
Senior Coder
Join Date: Aug 2006
Location: FL
Posts: 2,763
Thanks: 29
Thanked 453 Times in 447 Posts
Quote:
Originally Posted by
jmrker
And you still have un-matched <table>, <tr> and <td> tag sequences.
You also should not put code between tags, like: </td> <td> and </tr> <div> ... </div> <tr>
Quote:
Originally Posted by
WolfShade
Code:
<table>
<tr>
<td></td>
</tr>
</table>
Nothing in between. Anything else is not proper HTML, exception being if you are working in a server-side dynamic language.
That's what I was trying to say.
10-10-2012, 10:49 AM
PM User |
#8
New to the CF scene
Join Date: Oct 2012
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks all....I have made the changes...now no answers show!
other ideas very much appreciated
10-10-2012, 01:37 PM
PM User |
#9
Senior Coder
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
can you show us your revised code?
10-10-2012, 02:20 PM
PM User |
#10
New to the CF scene
Join Date: Oct 2012
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
yes...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Paranoid Thoughts</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="paranoidthoughts.css" type="text/css"
media="screen" />
<script type="text/javascript">
function toggle(value,divid){
if(value=='show') { document.getElementById('divid').style.display='block'; }
else { document.getElementById('divid').style.display='none'; }
}
</script>
<style type="text/css">
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<img src="paranoidimages/logos.png" alt="IoP Logo"> <br />
<img src="paranoidimages/oxfordlogo.jpg" alt="Oxford Logo">
</div>
<div id="header1">
<img src="paranoidimages/slam_logo.gif" alt="Slam Logo">
 
<img src="paranoidimages/Wellcome_Trust.jpg" alt"Wellcome logo">
</div>
<div id="parlogo">
<img alt='Paranoid thoughts' src='paranoidimages/logo.gif' border='0'/>
</div>
<div id="colortest">
</div>
<?php require_once('menu.php'); ?>
<h1>Assess your paranoia</h1>
<p>It's rare to go through life without having a paranoid thought. But how many people get these thoughts frequently?</p>
<p>We recently surveyed over a thousand people to see how many regularly had suspicious thoughts.</p>
<p>As you enter your response in the table below the results from the survey will be revealed.</p>
<p><em>Please note that this questionnaire only works in the Internet Explorer web browser.</em></p>
<h2>Paranoid thoughts questionnaire</h2>
<div class="q1">
<table width="100%">
<tr>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<td width="20%">I need to be on my guard against others</td>
<td width="15%"align="center"> <label class="choice">
<input id="Check" name="field_Payment" type="radio" value="rarely" class="required" onclick="toggle('show');">
Rarely</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="Paypal" name="field_Payment" type="radio" value="monthly" class="required" onclick="toggle('show');">
Once a month</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="weekly" name="field_Payment" type="radio" value="weekly" class="required" onclick="toggle('show');">
Once a week</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="several" name="field_Payment" type="radio" value="several" class="required" onclick="toggle('show');">
Several times a week</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="daily" name="field_Payment" type="radio" value="daily" class="required" onclick="toggle('show');">
Once a day</label></td>
</tr>
</table>
<div class="q1" style="display:none" id="mytext1">
<table width="100%" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="20%">Our survey said:</td>
<td width="15%" align="center"> 31%</td>
<td width="15%" align="center"> 17%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">10%</td>
</tr>
</div>
</table>
</td>
</tr>
</div>
<div class="q1" id="myText2">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20%">Negative comments about me might be being put around </td>
<td width="15%"align="center"> <label class="choice2">
<input id="Check2" name="field_Payment2" type="radio" value="rarely2" class="required" onclick="toggle('show','mytext2');">
Rarely</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="Paypal2" name="field_Payment2" type="radio" value="monthly2" class="required" onclick="toggle('show, 'mytext2');">
Once a month</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="weekly2" name="field_Payment2" type="radio" value="weekly2" class="required" onclick="toggle('show', 'mytext2');">
Once a week</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="several2" name="field_Payment2" type="radio" value="several2" class="required" onclick="toggle('show', 'mytext2');">
Several times a week</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="daily2" name="field_Payment2" type="radio" value="daily2" class="required" onclick="toggle('show', 'mytext2');">
Once a day</label></td>
</tr>
</table>
<div class="q1" style="display:none" id="mytext2">
<table>
<table width="100%" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="20%">Our survey said:</td>
<td width="15%" align="center"> 35%</td>
<td width="15%" align="center"> 24%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">14%</td>
<td width="15%" align="center">7%</td>
</tr>
</table>
</div>
</body>
</html>
10-10-2012, 02:27 PM
PM User |
#11
Senior Coder
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
two things - all your radio buttons should be passing the div id to the function, so the ones from question one would look like this:
Code:
<input id="Check" name="field_Payment" type="radio" value="rarely" class="required" onclick="toggle('show','mytext1');">
the other thing is that divid in your function is a variable, so remove the quote marks which are making it a string:
Code:
function toggle(value,divid){
if(value=='show') { document.getElementById(divid).style.display='block'; }
else { document.getElementById(divid).style.display='none'; }
}
10-10-2012, 02:56 PM
PM User |
#12
New to the CF scene
Join Date: Oct 2012
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Sadly this made no diffrenece at all. No answers appear when radio button is selected
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Paranoid Thoughts</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="paranoidthoughts.css" type="text/css"
media="screen" />
<script type="text/javascript">
function toggle(value,divid){
if(value==show) { document.getElementById('divid').style.display=block; }
else { document.getElementById('divid').style.display=none; }
}
</script>
<style type="text/css">
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<img src="paranoidimages/logos.png" alt="IoP Logo"> <br />
<img src="paranoidimages/oxfordlogo.jpg" alt="Oxford Logo">
</div>
<div id="header1">
<img src="paranoidimages/slam_logo.gif" alt="Slam Logo">
 
<img src="paranoidimages/Wellcome_Trust.jpg" alt"Wellcome logo">
</div>
<div id="parlogo">
<img alt='Paranoid thoughts' src='paranoidimages/logo.gif' border='0'/>
</div>
<div id="colortest">
</div>
<?php require_once('menu.php'); ?>
<h1>Assess your paranoia</h1>
<p>It's rare to go through life without having a paranoid thought. But how many people get these thoughts frequently?</p>
<p>We recently surveyed over a thousand people to see how many regularly had suspicious thoughts.</p>
<p>As you enter your response in the table below the results from the survey will be revealed.</p>
<p><em>Please note that this questionnaire only works in the Internet Explorer web browser.</em></p>
<h2>Paranoid thoughts questionnaire</h2>
<div class="q1" id="mytext1">
<table width="100%">
<tr>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<td width="20%">I need to be on my guard against others</td>
<td width="15%"align="center"> <label class="choice">
<input id="Check" name="field_Payment" type="radio" value="rarely" class="required" onclick="toggle('show','mytext1');">
Rarely</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="Paypal" name="field_Payment" type="radio" value="monthly" class="required" onclick="toggle('show','mytext1');">
Once a month</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="weekly" name="field_Payment" type="radio" value="weekly" class="required" onclick="toggle('show','mytext1');">
Once a week</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="several" name="field_Payment" type="radio" value="several" class="required" onclick="toggle('show','mytext1');">
Several times a week</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="daily" name="field_Payment" type="radio" value="daily" class="required" onclick="toggle('show','mytext1');">
Once a day</label></td>
</tr>
</table>
<div class="q1" style="display:none" id="mytext1">
<table width="100%" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="20%">Our survey said:</td>
<td width="15%" align="center"> 31%</td>
<td width="15%" align="center"> 17%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">10%</td>
</tr>
</div>
</table>
</td>
</tr>
</div>
<div class="q1" id="mytext2">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20%">Negative comments about me might be being put around </td>
<td width="15%"align="center"> <label class="choice2">
<input id="Check2" name="field_Payment2" type="radio" value="rarely2" class="required" onclick="toggle('show','mytext2');">
Rarely</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="Paypal2" name="field_Payment2" type="radio" value="monthly2" class="required" onclick="toggle('show,'mytext2');">
Once a month</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="weekly2" name="field_Payment2" type="radio" value="weekly2" class="required" onclick="toggle('show','mytext2');">
Once a week</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="several2" name="field_Payment2" type="radio" value="several2" class="required" onclick="toggle('show','mytext2');">
Several times a week</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="daily2" name="field_Payment2" type="radio" value="daily2" class="required" onclick="toggle('show','mytext2');">
Once a day</label></td>
</tr>
</table>
<div class="q1" style="display:none" id="mytext2">
<table>
<table width="100%" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="20%">Our survey said:</td>
<td width="15%" align="center"> 35%</td>
<td width="15%" align="center"> 24%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">14%</td>
<td width="15%" align="center">7%</td>
</tr>
</table>
</div>
</body>
</html>
10-10-2012, 03:05 PM
PM User |
#13
Senior Coder
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
Quote:
Originally Posted by
xelawho
the other thing is that divid in your function is a variable, so remove the quote marks which are making it a string:
Code:
function toggle(value,divid){
if(value=='show') { document.getElementById(divid).style.display='block'; }
else { document.getElementById(divid).style.display='none'; }
}
10-10-2012, 03:25 PM
PM User |
#14
New to the CF scene
Join Date: Oct 2012
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
thanks for your continued help but with or without quotes there is no diffrence...I have tried both, or have I missed somethiing?
10-10-2012, 03:43 PM
PM User |
#15
Senior Coder
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
sorry, I wasn't paying attention at how awry you have gone. The function should look like this:
Code:
function toggle(value,divid){
if(value=="show") { document.getElementById(divid).style.display="block"; }
else { document.getElementById(divid).style.display="none"; }
}
your code in post #12 has two elements each sharing the same ID. So we're back to square one. It works if your html looks like this:
Code:
<body>
<div id="wrap">
<div id="header">
<img src="paranoidimages/logos.png" alt="IoP Logo"> <br />
<img src="paranoidimages/oxfordlogo.jpg" alt="Oxford Logo">
</div>
<div id="header1">
<img src="paranoidimages/slam_logo.gif" alt="Slam Logo">
 
<img src="paranoidimages/Wellcome_Trust.jpg" alt"Wellcome logo">
</div>
<div id="parlogo">
<img alt='Paranoid thoughts' src='paranoidimages/logo.gif' border='0'/>
</div>
<div id="colortest">
</div>
<?php require_once('menu.php'); ?>
<h1>Assess your paranoia</h1>
<p>It's rare to go through life without having a paranoid thought. But how many people get these thoughts frequently?</p>
<p>We recently surveyed over a thousand people to see how many regularly had suspicious thoughts.</p>
<p>As you enter your response in the table below the results from the survey will be revealed.</p>
<p><em>Please note that this questionnaire only works in the Internet Explorer web browser.</em></p>
<h2>Paranoid thoughts questionnaire</h2>
<div class="q1" >
<table width="100%">
<tr>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<td width="20%">I need to be on my guard against others</td>
<td width="15%"align="center"> <label class="choice">
<input id="Check" name="field_Payment" type="radio" value="rarely" class="required" onclick="toggle('show','mytext1');">
Rarely</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="Paypal" name="field_Payment" type="radio" value="monthly" class="required" onclick="toggle('show','mytext1');">
Once a month</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="weekly" name="field_Payment" type="radio" value="weekly" class="required" onclick="toggle('show','mytext1');">
Once a week</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="several" name="field_Payment" type="radio" value="several" class="required" onclick="toggle('show','mytext1');">
Several times a week</label></td>
 
<td width="15%"align="center"> <label class="choice">
<input id="daily" name="field_Payment" type="radio" value="daily" class="required" onclick="toggle('show','mytext1');">
Once a day</label></td>
</tr>
</table>
<div class="q1" style="display:none" id="mytext1">
<table width="100%" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="20%">Our survey said:</td>
<td width="15%" align="center"> 31%</td>
<td width="15%" align="center"> 17%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">10%</td>
</tr>
</div>
</table>
</td>
</tr>
</div>
<div class="q1" >
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20%">Negative comments about me might be being put around </td>
<td width="15%"align="center"> <label class="choice2">
<input id="Check2" name="field_Payment2" type="radio" value="rarely2" class="required" onclick="toggle('show','mytext2');">
Rarely</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="Paypal2" name="field_Payment2" type="radio" value="monthly2" class="required" onclick="toggle('show,'mytext2');">
Once a month</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="weekly2" name="field_Payment2" type="radio" value="weekly2" class="required" onclick="toggle('show','mytext2');">
Once a week</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="several2" name="field_Payment2" type="radio" value="several2" class="required" onclick="toggle('show','mytext2');">
Several times a week</label></td>
 
<td width="15%"align="center"> <label class="choice2">
<input id="daily2" name="field_Payment2" type="radio" value="daily2" class="required" onclick="toggle('show','mytext2');">
Once a day</label></td>
</tr>
</table>
<div class="q1" style="display:none" id="mytext2">
<table>
<table width="100%" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="20%">Our survey said:</td>
<td width="15%" align="center"> 35%</td>
<td width="15%" align="center"> 24%</td>
<td width="15%" align="center">21%</td>
<td width="15%" align="center">14%</td>
<td width="15%" align="center">7%</td>
</tr>
</table>
</div>
</body>
Users who have thanked xelawho for this post:
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 01:02 AM .
Advertisement
Log in to turn off these ads.