Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    New Coder
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    2
    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>
    &nbsp
    <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>
    &nbsp
    <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>
    &nbsp
    <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>
    &nbsp
    <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>
    &nbsp
    <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>
    &nbsp
    <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>
    &nbsp
    <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>
    &nbsp
    <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]

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 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".

  • #3
    New Coder
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    2
    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">
    	&nbsp
    		<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>
     &nbsp
     <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>
    		&nbsp
    <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>
    		&nbsp
    <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>
    		&nbsp
    <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>
     &nbsp
     <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>
    		&nbsp
    <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>
    		&nbsp
    <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>
    		&nbsp
    <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>

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,918
    Thanks
    56
    Thanked 545 Times in 542 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...)

  • #5
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,076
    Thanks
    38
    Thanked 498 Times in 492 Posts
    And you still have un-matched <table>, <tr> and <td> tag sequences.

    You also should not put code between tags, like: </td> &nbsp; <td> and </tr> <div> ... </div> <tr>

  • #6
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 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".

  • #7
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,076
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Arrow

    Quote Originally Posted by jmrker View Post
    And you still have un-matched <table>, <tr> and <td> tag sequences.

    You also should not put code between tags, like: </td> &nbsp; <td> and </tr> <div> ... </div> <tr>
    Quote Originally Posted by WolfShade View Post
    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.

  • #8
    New Coder
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks all....I have made the changes...now no answers show!

    other ideas very much appreciated

  • #9
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,918
    Thanks
    56
    Thanked 545 Times in 542 Posts
    can you show us your revised code?

  • #10
    New Coder
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    2
    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">
    	&nbsp
    		<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>
     &nbsp
    
     <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>
    		&nbsp
    
    <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>
    		&nbsp
    
    <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>
    		&nbsp
    
    <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>
     &nbsp
    
     <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>
    		&nbsp
    
    <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>
    		&nbsp
    
    <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>
    		&nbsp
    
    <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>

  • #11
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,918
    Thanks
    56
    Thanked 545 Times in 542 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'; }
    }

  • #12
    New Coder
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    2
    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">
    	&nbsp
    		<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>
     &nbsp
    
     <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>
    		&nbsp
    
    <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>
    		&nbsp
    
    <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>
    		&nbsp
    
    <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>
     &nbsp
    
     <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>
    		&nbsp
    
    <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>
    		&nbsp
    
    <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>
    		&nbsp
    
    <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>

  • #13
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,918
    Thanks
    56
    Thanked 545 Times in 542 Posts
    Quote Originally Posted by xelawho View Post
    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'; }
    }

  • #14
    New Coder
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    2
    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?

  • #15
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,918
    Thanks
    56
    Thanked 545 Times in 542 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">
    	&nbsp
    		<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>
     &nbsp
     <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>
    		&nbsp
    <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>
    		&nbsp
    <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>
    		&nbsp
    <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>
     &nbsp
     <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>
    		&nbsp
    <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>
    		&nbsp
    <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>
    		&nbsp
    <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:

    dp76 (10-10-2012)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •