ID undefined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charliecharlesA
    New Member
    • Nov 2007
    • 3

    ID undefined

    i am currently designing a form and am having trouble with a piece of java when i put it in the document...

    The following works fine by itself, and even when i put it in other documents, however when i place it in the document i need and FireBug it, it says that the id "yesno" is not defined... Any ideas?

    Code:
    <style>
    /* Normal style */
    	 .normal {
    	  font-family: Comic Sans MS, sans-serif; 
    	 }
    	 
    	/* Display block */
    	 .DisplayBlock {
    	  display : block;
    	}
    	/* Display none */
    	 .DisplayNone {
    	  display: none;
    	 }
    	
    </style>
    <script language="javascript">
    function classChange(element,newclass) {
    	element.className = newclass;
    	}
    </script>
    <table>
    <tr><td>
    		<input type="radio" name="Updates" value="yes" onClick="classChange(undisplayed,'DisplayNone')">No
    		<br>
    	 <input type="radio" name="Updates" value="yes" onClick="classChange(undisplayed,'DisplayBlock')">Yes
    	<p class="DisplayNone" id="undisplayed">
    	<!-- Marker1 --><textarea name="UpdateDetails" cols="70" rows="3"></textarea>
    	</p> 
    	</td></tr>
    </table>
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    hi ...

    welcome to TSDN ...

    the code you just posted works ... so please post one that is no working ... so that we may have a closer look at it ...

    kind regards

    Comment

    • charliecharlesA
      New Member
      • Nov 2007
      • 3

      #3
      Here is another attempt. I have two attempts at the same thing with different javascripts. I can't get either method to recognize the ID tag I am assigning to the text box.

      Code:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <title>Document Submission Form</title>
      <style type="text/css">
      body {
      font-family:Arial, Helvetica, sans-serif;
      }
      
      <!-- Classes>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>-->
      .CourseTitle {
      font:"Trebuchet MS", Arial, Helvetica, sans-serif;
      font-size:22px;
      font-weight:bold;
      }
      
      .WhiteHeader{
      font:"Trebuchet MS";
      font-size:20px;
      font-weight:bold;
      color:#FFFFFF;
      }
      
      .changedField {
      	color: white;
      	background-color: navy;
      }
      
      .currentField {
      color:white;
      background: red;
      }
      .greyBG , .greyBG TD, .greyBG TH {
      background:#999999;
      }
      
      .darkgreyBG, .darkgreyBG TD, .darkgreyBG TH {
      background-color:#666666;
      }
      .indent {
      padding-left:25px;
      }
      #CourseIsText{
      padding-left:25px;}
      
      .DisplayNone{
      display:none}
      
      .DisplayBlock{
      display:block}
      </style>
      
      <script type="text/javascript">
      function classChange(element,newclass) {
      	element.className = newclass;
      	}
      function Show_Stuff(Click_Menu)
      // Function that will swap the display/no display for
      // all content within span tags
      {
      if (Click_Menu.style.display == "none")
      {
      Click_Menu.style.display = "";
      }
      else
      {
      Click_Menu.style.display = "none";
      }
      }
      </script>
      
      </head>
      
      <body>
      <form action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi"
      enctype="multipart/form-data" method="post" name="CourseContent">
        <table cellspacing="0" cellpadding="0" border="1" align="center" frame="void" rules="groups" width="887" >
        <tbody>
        <tr>
          <td colspan="4">
      	<div align="center" class="darkgreyBG WhiteHeader"><strong> CONTENT DEVELOPMENT INFORMATION </strong></div></td>
        </tr>
        </tbody>
        <tbody>
        <tr>
          <td colspan="2" valign="bottom" class="greyBG"><div align="center"><strong> State/Vertical </strong></div></td>
          <td width="289" valign="bottom" class="greyBG"><div align="center"><strong> Seat Hours </strong></div></td>
          <td width="178" valign="bottom" class="greyBG"><div align="center"><strong> Credit Hours</strong><strong></strong></div></td>
        </tr>
        </tbody>
        <tbody>
        <tr>
          <td colspan="2"><div align="center"><a name="Text1"></a>
      	<input name="SubmitDate" 
      	type="text" 
      	
      	value="" 
      	size="50"></div></td>
          <td width="289"><div align="center"><input name="SubmitDate" 
      	type="text" 
      	
      	value="" 
      	size="10">
          </div></td>
          <td width="178"><div align="center"><input name="SubmitDate" 
      	type="text" 
      
      	value="" 
      	size="10"></div></td>
        </tr>
        </tbody>
        <tr>
          <td colspan="4"><div align="center" class="greyBG"><strong> COURSE CONTENT </strong></div></td>
        </tr>
        <tbody>
        <tr>
          <td width="353"><p><strong> This course is a: </strong></p>
              <p><strong> &nbsp;</strong></p>
              <p> Note: If this is a revision or update, please include any Course IDs that will be updated. </p></td>
          <td colspan="3">
                <p>
                  <input type="radio" name="CourseIs" />New Course</p>
                <p>
          <input type="radio" name="CourseIs" onClick="Show_Stuff(display2)"/>
      	    Revision or Update to an Existing Course<br/>
                <div class="indent"><span id="display2" STYLE="display: none"><textarea name="RevDetails" cols="70" rows="3"></textarea></span></div>
      </td>
        </tr>
        </tbody>
        <tbody>
        <tr>
        <td width="353"><p><strong> This course is a: </strong></p>
              <p><strong> &nbsp;</strong></p>
              <p> Note: If this is a revision or update, please include any Course IDs that will be updated. </p></td>
          <td colspan="3">
              
            <p>
                  <input type="radio" name="CourseIs" value="New Course" onClick="classChange(yesno,'DisplayNone')"/>
                New Course</p>
            <p>
              <input type="radio" name="CourseIs" value="revision" onClick="classChange(yesno,'DisplayBlock')"/>
                  Revision or Update to an Existing Course<br/>
                </p>
            <div class="indent DisplayNone" id="yesno"><textarea name="RevDetails" cols="70" rows="3"></textarea></div>
      </td>
        </tr>
        </tbody>
      </table>
      
      </body>
      </html>

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        hi ...

        i think you have to pass the value as a string ... it would be undefined otherwise ... since javascript assumes that is a variable when passing it the way jou did:

        [CODE=javascript]onclick="classC hange('yesno', 'DisplayBlock') ;"[/CODE]
        kind regards

        ps: the same goes for Show_Stuff('dis play2');

        Comment

        • charliecharlesA
          New Member
          • Nov 2007
          • 3

          #5
          I don't know what you are suggesting... more javascript code? parentheses?

          If i want to use the same javascript function to display/hide various elements do i need to define the value of each instance?

          Translation: WHAT?

          Comment

          • Dasty
            Recognized Expert New Member
            • Nov 2007
            • 101

            #6
            shoudn't it be:

            [code=javascript]
            onClick="classC hange(document. getElementById( 'yesno'),'Displ ayNone');"
            and
            onClick="Show_S tuff(document.g etElementById(' display2'));"
            [/code]
            ?

            Comment

            • gits
              Recognized Expert Moderator Expert
              • May 2007
              • 5388

              #7
              Originally posted by Dasty
              shoudn't it be:

              [code=javascript]
              onClick="classC hange(document. getElementById( 'yesno'),'Displ ayNone');"
              and
              onClick="Show_S tuff(document.g etElementById(' display2'));"
              [/code]
              ?
              yes ... of course ;) thanks for pointing that out ...

              kind regards

              Comment

              Working...